﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Ketoan
{
	/// <summary>
	/// Summary description for frmReportPublic.
	/// </summary>
	public class frmReportCTGS : System.Windows.Forms.Form
	{
		//Khai bao gia tri mau cho form
		private int i_Red=255,i_Green=255,i_Blue=195;

		//Khai bao bien su dung trong form.
		#region Khai bao cac bien su dung trong form.
		private LibKetoan.AccessData a;
		private string s_Tenform="",s_fTieude_chinh="",s_Pagesize="A4";
		private int i_HChuong=0,i_HTaikhoan=0,i_HLoaikhoan=0,i_HMuc=0,i_HHoatdong=0,i_HKhoaphong=0,i_HDoituong=0;
		private int i_HKhoanmuc=0,i_HNhombc=0,i_Kieuin=1, i_Banin=1; 
		private bool b_Lctu=true,b_Khoanmuc=true;
		
		private Print_kt Print=new Print_kt();
		private exportExcel exportExcel=new exportExcel();
		private System.Data.DataRow r;
		private System.Data.DataTable dt_Dmchuong,dt_Dmtk,dt_Dmlk,dt_Dmmuc,dt_Dmhoatdong;
		private System.Data.DataTable dt_Dmkhoaphong,dt_Dmdoituong,dt_Dmnhombc,dt_Dmkhoanmuc;
		private System.Data.DataSet ds_Data;
		private string s_Report="";
		#endregion Khai bao bien su dung trong form.

		#region Cac control su dung trong form.

		private System.Windows.Forms.Button butXem;
		private System.Windows.Forms.Button butIn;
		private System.Windows.Forms.Button butKetthuc;
		private LibList.List listLoaikhoan;
		private LibList.List listTaikhoan;
		private txtListBox.txtListBox txtSotaikhoan;
		private txtListBox.txtListBox txtLoaikhoan;
		protected txtListBox.txtListBox txtTentaikhoan;
		protected txtListBox.txtListBox txtTenloaikhoan;
		private System.Windows.Forms.NumericUpDown numDenthang;
		private System.Windows.Forms.NumericUpDown numTuthang;
		private System.Windows.Forms.NumericUpDown numNam;
		private System.Windows.Forms.GroupBox grbThang;
		private System.Windows.Forms.RadioButton rdbTheongay;
		private System.Windows.Forms.RadioButton rdbTheothang;
		private System.Windows.Forms.GroupBox grbNgay;
		private System.Windows.Forms.ComboBox cboLoaibc;
		private System.Windows.Forms.DateTimePicker dtpDenngay;
		private System.Windows.Forms.DateTimePicker dtpTungay;
		private System.Windows.Forms.Label lblLoaikhoan;
		private System.Windows.Forms.Label lblChucnang;
		private System.Windows.Forms.Label lblLoaibc;
		private System.Windows.Forms.Label lblMuc;
		protected txtListBox.txtListBox txtTenmuc;
		private txtListBox.txtListBox txtMuc;
		private LibList.List listMuc;
		private txtListBox.txtListBox txtTenhoatdong;
		private System.Windows.Forms.Label lblHoatdong;
		private txtListBox.txtListBox txtHoatdong;
		private LibList.List listHoatdong;
		private System.Windows.Forms.Label lblError;
		private System.Windows.Forms.GroupBox grbCheck;
		private txtListBox.txtListBox txtChuong;
		private txtListBox.txtListBox txtTenchuong;
		private LibList.List listChuong;
		private System.Windows.Forms.Label lblChuong;
		private LibList.List listKhoaphong;
		private txtListBox.txtListBox txtTenkhoaphong;
		private txtListBox.txtListBox txtKhoaphong;
		private System.Windows.Forms.Label lblKhoaphong;
		private LibList.List listDoituong;
		private txtListBox.txtListBox txtTendoituong;
		private txtListBox.txtListBox txtDoituong;
		private System.Windows.Forms.Label lblDoituong;
		private System.Windows.Forms.Label lblTuthang;
		private System.Windows.Forms.Label lblDenthang;
		private System.Windows.Forms.Label lblDenngay;
		private System.Windows.Forms.Label lblTungay;
		private System.Windows.Forms.Label lblNam;
		private System.Windows.Forms.Button butExcel;
		private System.Windows.Forms.Label lblNhombc;
		private System.Windows.Forms.ComboBox cboNhombc;
		private txtListBox.txtListBox txtNhombc;
		private LibList.List listNhombc;
		private txtListBox.txtListBox txtKhoanmuc;
		private System.Windows.Forms.Label lblKhoanmuc;
		private LibList.List listKhoanmuc;
		protected txtListBox.txtListBox txtTenkhoanmuc;
		private System.Windows.Forms.GroupBox grpNen;

		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
	
		#endregion Cac control su dung trong form.

		public frmReportCTGS(LibKetoan.AccessData acc,string s_Form)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			a=acc;
			s_Tenform=s_Form;
			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
			try
			{
				GC.Collect();
				a.Dispose();
				ds_Data.Dispose();
				dt_Dmchuong.Dispose();
				dt_Dmtk.Dispose();
				dt_Dmlk.Dispose();
				dt_Dmmuc.Dispose();
				dt_Dmhoatdong.Dispose();
				dt_Dmkhoaphong.Dispose();
				dt_Dmdoituong.Dispose();
			}
			catch{};
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmReportCTGS));
			this.butXem = new System.Windows.Forms.Button();
			this.butIn = new System.Windows.Forms.Button();
			this.butKetthuc = new System.Windows.Forms.Button();
			this.listLoaikhoan = new LibList.List();
			this.listTaikhoan = new LibList.List();
			this.lblLoaikhoan = new System.Windows.Forms.Label();
			this.lblChucnang = new System.Windows.Forms.Label();
			this.txtSotaikhoan = new txtListBox.txtListBox();
			this.txtLoaikhoan = new txtListBox.txtListBox();
			this.txtTentaikhoan = new txtListBox.txtListBox();
			this.txtTenloaikhoan = new txtListBox.txtListBox();
			this.grbThang = new System.Windows.Forms.GroupBox();
			this.numDenthang = new System.Windows.Forms.NumericUpDown();
			this.numTuthang = new System.Windows.Forms.NumericUpDown();
			this.numNam = new System.Windows.Forms.NumericUpDown();
			this.lblDenthang = new System.Windows.Forms.Label();
			this.lblTuthang = new System.Windows.Forms.Label();
			this.lblNam = new System.Windows.Forms.Label();
			this.grbNgay = new System.Windows.Forms.GroupBox();
			this.dtpDenngay = new System.Windows.Forms.DateTimePicker();
			this.lblDenngay = new System.Windows.Forms.Label();
			this.dtpTungay = new System.Windows.Forms.DateTimePicker();
			this.lblTungay = new System.Windows.Forms.Label();
			this.grbCheck = new System.Windows.Forms.GroupBox();
			this.rdbTheothang = new System.Windows.Forms.RadioButton();
			this.rdbTheongay = new System.Windows.Forms.RadioButton();
			this.lblLoaibc = new System.Windows.Forms.Label();
			this.cboLoaibc = new System.Windows.Forms.ComboBox();
			this.txtTenmuc = new txtListBox.txtListBox();
			this.txtMuc = new txtListBox.txtListBox();
			this.lblMuc = new System.Windows.Forms.Label();
			this.listMuc = new LibList.List();
			this.txtTenhoatdong = new txtListBox.txtListBox();
			this.lblHoatdong = new System.Windows.Forms.Label();
			this.txtHoatdong = new txtListBox.txtListBox();
			this.listHoatdong = new LibList.List();
			this.lblError = new System.Windows.Forms.Label();
			this.txtChuong = new txtListBox.txtListBox();
			this.lblChuong = new System.Windows.Forms.Label();
			this.listChuong = new LibList.List();
			this.txtTenchuong = new txtListBox.txtListBox();
			this.listKhoaphong = new LibList.List();
			this.txtTenkhoaphong = new txtListBox.txtListBox();
			this.txtKhoaphong = new txtListBox.txtListBox();
			this.lblKhoaphong = new System.Windows.Forms.Label();
			this.listDoituong = new LibList.List();
			this.txtTendoituong = new txtListBox.txtListBox();
			this.txtDoituong = new txtListBox.txtListBox();
			this.lblDoituong = new System.Windows.Forms.Label();
			this.butExcel = new System.Windows.Forms.Button();
			this.lblNhombc = new System.Windows.Forms.Label();
			this.cboNhombc = new System.Windows.Forms.ComboBox();
			this.txtNhombc = new txtListBox.txtListBox();
			this.listNhombc = new LibList.List();
			this.txtKhoanmuc = new txtListBox.txtListBox();
			this.lblKhoanmuc = new System.Windows.Forms.Label();
			this.listKhoanmuc = new LibList.List();
			this.txtTenkhoanmuc = new txtListBox.txtListBox();
			this.grpNen = new System.Windows.Forms.GroupBox();
			this.grbThang.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.numDenthang)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.numTuthang)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.numNam)).BeginInit();
			this.grbNgay.SuspendLayout();
			this.grbCheck.SuspendLayout();
			this.SuspendLayout();
			// 
			// butXem
			// 
			this.butXem.BackColor = System.Drawing.SystemColors.Control;
			this.butXem.ForeColor = System.Drawing.SystemColors.WindowText;
			this.butXem.Image = ((System.Drawing.Bitmap)(resources.GetObject("butXem.Image")));
			this.butXem.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butXem.Location = new System.Drawing.Point(116, 344);
			this.butXem.Name = "butXem";
			this.butXem.Size = new System.Drawing.Size(60, 25);
			this.butXem.TabIndex = 80;
			this.butXem.Text = "     &Xem";
			this.butXem.Click += new System.EventHandler(this.butXem_Click);
			this.butXem.KeyDown += new System.Windows.Forms.KeyEventHandler(this.event_KeyDown);
			// 
			// butIn
			// 
			this.butIn.BackColor = System.Drawing.SystemColors.Control;
			this.butIn.ForeColor = System.Drawing.SystemColors.WindowText;
			this.butIn.Image = ((System.Drawing.Bitmap)(resources.GetObject("butIn.Image")));
			this.butIn.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butIn.Location = new System.Drawing.Point(240, 344);
			this.butIn.Name = "butIn";
			this.butIn.Size = new System.Drawing.Size(60, 25);
			this.butIn.TabIndex = 82;
			this.butIn.Text = "     &In";
			this.butIn.Click += new System.EventHandler(this.butIn_Click);
			this.butIn.KeyDown += new System.Windows.Forms.KeyEventHandler(this.event_KeyDown);
			// 
			// butKetthuc
			// 
			this.butKetthuc.BackColor = System.Drawing.SystemColors.Control;
			this.butKetthuc.ForeColor = System.Drawing.SystemColors.WindowText;
			this.butKetthuc.Image = ((System.Drawing.Bitmap)(resources.GetObject("butKetthuc.Image")));
			this.butKetthuc.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butKetthuc.Location = new System.Drawing.Point(302, 344);
			this.butKetthuc.Name = "butKetthuc";
			this.butKetthuc.Size = new System.Drawing.Size(68, 25);
			this.butKetthuc.TabIndex = 83;
			this.butKetthuc.Text = "&Kết thúc";
			this.butKetthuc.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.butKetthuc.Click += new System.EventHandler(this.butKetthuc_Click);
			this.butKetthuc.KeyDown += new System.Windows.Forms.KeyEventHandler(this.event_KeyDown);
			// 
			// listLoaikhoan
			// 
			this.listLoaikhoan.BackColor = System.Drawing.SystemColors.Info;
			this.listLoaikhoan.ColumnCount = 0;
			this.listLoaikhoan.Location = new System.Drawing.Point(176, 368);
			this.listLoaikhoan.MatchBufferTimeOut = 1000;
			this.listLoaikhoan.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
			this.listLoaikhoan.Name = "listLoaikhoan";
			this.listLoaikhoan.Size = new System.Drawing.Size(75, 17);
			this.listLoaikhoan.TabIndex = 103;
			this.listLoaikhoan.TextIndex = -1;
			this.listLoaikhoan.TextMember = null;
			this.listLoaikhoan.ValueIndex = -1;
			this.listLoaikhoan.Visible = false;
			// 
			// listTaikhoan
			// 
			this.listTaikhoan.BackColor = System.Drawing.SystemColors.Info;
			this.listTaikhoan.ColumnCount = 0;
			this.listTaikhoan.Location = new System.Drawing.Point(96, 368);
			this.listTaikhoan.MatchBufferTimeOut = 1000;
			this.listTaikhoan.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
			this.listTaikhoan.Name = "listTaikhoan";
			this.listTaikhoan.Size = new System.Drawing.Size(75, 17);
			this.listTaikhoan.TabIndex = 102;
			this.listTaikhoan.TextIndex = -1;
			this.listTaikhoan.TextMember = null;
			this.listTaikhoan.ValueIndex = -1;
			this.listTaikhoan.Visible = false;
			// 
			// lblLoaikhoan
			// 
			this.lblLoaikhoan.BackColor = System.Drawing.SystemColors.Control;
			this.lblLoaikhoan.ForeColor = System.Drawing.Color.DarkBlue;
			this.lblLoaikhoan.Location = new System.Drawing.Point(16, 133);
			this.lblLoaikhoan.Name = "lblLoaikhoan";
			this.lblLoaikhoan.Size = new System.Drawing.Size(80, 23);
			this.lblLoaikhoan.TabIndex = 36;
			this.lblLoaikhoan.Text = "Loại khoản :";
			this.lblLoaikhoan.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.lblLoaikhoan.Visible = false;
			// 
			// lblChucnang
			// 
			this.lblChucnang.BackColor = System.Drawing.SystemColors.Control;
			this.lblChucnang.ForeColor = System.Drawing.Color.DarkBlue;
			this.lblChucnang.Location = new System.Drawing.Point(16, 110);
			this.lblChucnang.Name = "lblChucnang";
			this.lblChucnang.Size = new System.Drawing.Size(80, 23);
			this.lblChucnang.TabIndex = 33;
			this.lblChucnang.Text = "Chức năng :";
			this.lblChucnang.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.lblChucnang.Visible = false;
			// 
			// txtSotaikhoan
			// 
			this.txtSotaikhoan.BackColor = System.Drawing.SystemColors.Window;
			this.txtSotaikhoan.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtSotaikhoan.ForeColor = System.Drawing.Color.DarkBlue;
			this.txtSotaikhoan.Location = new System.Drawing.Point(103, 110);
			this.txtSotaikhoan.Name = "txtSotaikhoan";
			this.txtSotaikhoan.Size = new System.Drawing.Size(63, 21);
			this.txtSotaikhoan.TabIndex = 34;
			this.txtSotaikhoan.Text = "";
			this.txtSotaikhoan.Visible = false;
			this.txtSotaikhoan.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtSotaikhoan_KeyDown);
			this.txtSotaikhoan.DoubleClick += new System.EventHandler(this.txtSotaikhoan_DoubleClick);
			this.txtSotaikhoan.Validated += new System.EventHandler(this.txtSotaikhoan_Validated);
			this.txtSotaikhoan.TextChanged += new System.EventHandler(this.txtSotaikhoan_TextChanged);
			// 
			// txtLoaikhoan
			// 
			this.txtLoaikhoan.BackColor = System.Drawing.SystemColors.Window;
			this.txtLoaikhoan.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtLoaikhoan.ForeColor = System.Drawing.Color.DarkBlue;
			this.txtLoaikhoan.Location = new System.Drawing.Point(103, 133);
			this.txtLoaikhoan.Name = "txtLoaikhoan";
			this.txtLoaikhoan.Size = new System.Drawing.Size(63, 21);
			this.txtLoaikhoan.TabIndex = 37;
			this.txtLoaikhoan.Text = "";
			this.txtLoaikhoan.Visible = false;
			this.txtLoaikhoan.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtLoaikhoan_KeyDown);
			this.txtLoaikhoan.DoubleClick += new System.EventHandler(this.txtLoaikhoan_DoubleClick);
			this.txtLoaikhoan.Validated += new System.EventHandler(this.txtLoaikhoan_Validated);
			this.txtLoaikhoan.TextChanged += new System.EventHandler(this.txtLoaikhoan_TextChanged);
			// 
			// txtTentaikhoan
			// 
			this.txtTentaikhoan.BackColor = System.Drawing.SystemColors.Window;
			this.txtTentaikhoan.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtTentaikhoan.ForeColor = System.Drawing.Color.DarkBlue;
			this.txtTentaikhoan.Location = new System.Drawing.Point(168, 110);
			this.txtTentaikhoan.Name = "txtTentaikhoan";
			this.txtTentaikhoan.ReadOnly = true;
			this.txtTentaikhoan.Size = new System.Drawing.Size(296, 21);
			this.txtTentaikhoan.TabIndex = 35;
			this.txtTentaikhoan.TabStop = false;
			this.txtTentaikhoan.Text = "";
			this.txtTentaikhoan.Visible = false;
			this.txtTentaikhoan.KeyDown += new System.Windows.Forms.KeyEventHandler(this.event_KeyDown);
			// 
			// txtTenloaikhoan
			// 
			this.txtTenloaikhoan.BackColor = System.Drawing.SystemColors.Window;
			this.txtTenloaikhoan.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtTenloaikhoan.ForeColor = System.Drawing.Color.DarkBlue;
			this.txtTenloaikhoan.Location = new System.Drawing.Point(168, 133);
			this.txtTenloaikhoan.Name = "txtTenloaikhoan";
			this.txtTenloaikhoan.ReadOnly = true;
			this.txtTenloaikhoan.Size = new System.Drawing.Size(296, 21);
			this.txtTenloaikhoan.TabIndex = 38;
			this.txtTenloaikhoan.TabStop = false;
			this.txtTenloaikhoan.Text = "";
			this.txtTenloaikhoan.Visible = false;
			this.txtTenloaikhoan.KeyDown += new System.Windows.Forms.KeyEventHandler(this.event_KeyDown);
			// 
			// grbThang
			// 
			this.grbThang.Controls.AddRange(new System.Windows.Forms.Control[] {
																				   this.numDenthang,
																				   this.numTuthang,
																				   this.numNam,
																				   this.lblDenthang,
																				   this.lblTuthang,
																				   this.lblNam});
			this.grbThang.Enabled = false;
			this.grbThang.Location = new System.Drawing.Point(105, 40);
			this.grbThang.Name = "grbThang";
			this.grbThang.Size = new System.Drawing.Size(374, 36);
			this.grbThang.TabIndex = 3;
			this.grbThang.TabStop = false;
			// 
			// numDenthang
			// 
			this.numDenthang.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.numDenthang.ForeColor = System.Drawing.Color.DarkBlue;
			this.numDenthang.Location = new System.Drawing.Point(148, 9);
			this.numDenthang.Maximum = new System.Decimal(new int[] {
																		12,
																		0,
																		0,
																		0});
			this.numDenthang.Minimum = new System.Decimal(new int[] {
																		1,
																		0,
																		0,
																		0});
			this.numDenthang.Name = "numDenthang";
			this.numDenthang.Size = new System.Drawing.Size(38, 21);
			this.numDenthang.TabIndex = 22;
			this.numDenthang.Value = new System.Decimal(new int[] {
																	  1,
																	  0,
																	  0,
																	  0});
			this.numDenthang.Enter += new System.EventHandler(this.numDenthang_Enter);
			this.numDenthang.KeyDown += new System.Windows.Forms.KeyEventHandler(this.event_KeyDown);
			this.numDenthang.Leave += new System.EventHandler(this.numDenthang_Leave);
			// 
			// numTuthang
			// 
			this.numTuthang.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.numTuthang.ForeColor = System.Drawing.Color.DarkBlue;
			this.numTuthang.Location = new System.Drawing.Point(64, 9);
			this.numTuthang.Maximum = new System.Decimal(new int[] {
																	   12,
																	   0,
																	   0,
																	   0});
			this.numTuthang.Minimum = new System.Decimal(new int[] {
																	   1,
																	   0,
																	   0,
																	   0});
			this.numTuthang.Name = "numTuthang";
			this.numTuthang.Size = new System.Drawing.Size(38, 21);
			this.numTuthang.TabIndex = 20;
			this.numTuthang.Value = new System.Decimal(new int[] {
																	 1,
																	 0,
																	 0,
																	 0});
			this.numTuthang.Enter += new System.EventHandler(this.numTuthang_Enter);
			this.numTuthang.KeyDown += new System.Windows.Forms.KeyEventHandler(this.event_KeyDown);
			this.numTuthang.Leave += new System.EventHandler(this.numTuthang_Leave);
			// 
			// numNam
			// 
			this.numNam.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.numNam.ForeColor = System.Drawing.Color.DarkBlue;
			this.numNam.Location = new System.Drawing.Point(230, 9);
			this.numNam.Maximum = new System.Decimal(new int[] {
																   3004,
																   0,
																   0,
																   0});
			this.numNam.Minimum = new System.Decimal(new int[] {
																   2004,
																   0,
																   0,
																   0});
			this.numNam.Name = "numNam";
			this.numNam.Size = new System.Drawing.Size(48, 21);
			this.numNam.TabIndex = 24;
			this.numNam.Value = new System.Decimal(new int[] {
																 2004,
																 0,
																 0,
																 0});
			this.numNam.Enter += new System.EventHandler(this.numNam_Enter);
			this.numNam.KeyDown += new System.Windows.Forms.KeyEventHandler(this.event_KeyDown);
			this.numNam.Leave += new System.EventHandler(this.numNam_Leave);
			// 
			// lblDenthang
			// 
			this.lblDenthang.BackColor = System.Drawing.SystemColors.Control;
			this.lblDenthang.ForeColor = System.Drawing.Color.DarkBlue;
			this.lblDenthang.Location = new System.Drawing.Point(108, 9);
			this.lblDenthang.Name = "lblDenthang";
			this.lblDenthang.Size = new System.Drawing.Size(32, 23);
			this.lblDenthang.TabIndex = 21;
			this.lblDenthang.Text = "đến ";
			this.lblDenthang.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// lblTuthang
			// 
			this.lblTuthang.BackColor = System.Drawing.SystemColors.Control;
			this.lblTuthang.ForeColor = System.Drawing.Color.DarkBlue;
			this.lblTuthang.Location = new System.Drawing.Point(10, 9);
			this.lblTuthang.Name = "lblTuthang";
			this.lblTuthang.Size = new System.Drawing.Size(49, 23);
			this.lblTuthang.TabIndex = 19;
			this.lblTuthang.Text = "Từ tháng";
			this.lblTuthang.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// lblNam
			// 
			this.lblNam.BackColor = System.Drawing.SystemColors.Control;
			this.lblNam.ForeColor = System.Drawing.Color.DarkBlue;
			this.lblNam.Location = new System.Drawing.Point(189, 9);
			this.lblNam.Name = "lblNam";
			this.lblNam.Size = new System.Drawing.Size(34, 23);
			this.lblNam.TabIndex = 23;
			this.lblNam.Text = "năm";
			this.lblNam.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// grbNgay
			// 
			this.grbNgay.Controls.AddRange(new System.Windows.Forms.Control[] {
																				  this.dtpDenngay,
																				  this.lblDenngay,
																				  this.dtpTungay,
																				  this.lblTungay});
			this.grbNgay.Location = new System.Drawing.Point(105, 10);
			this.grbNgay.Name = "grbNgay";
			this.grbNgay.Size = new System.Drawing.Size(374, 36);
			this.grbNgay.TabIndex = 2;
			this.grbNgay.TabStop = false;
			// 
			// dtpDenngay
			// 
			this.dtpDenngay.CustomFormat = "dd/MM/yyyy";
			this.dtpDenngay.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.dtpDenngay.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
			this.dtpDenngay.Location = new System.Drawing.Point(198, 9);
			this.dtpDenngay.Name = "dtpDenngay";
			this.dtpDenngay.Size = new System.Drawing.Size(80, 21);
			this.dtpDenngay.TabIndex = 18;
			this.dtpDenngay.Enter += new System.EventHandler(this.dtpDenngay_Enter);
			this.dtpDenngay.KeyDown += new System.Windows.Forms.KeyEventHandler(this.event_KeyDown);
			this.dtpDenngay.Leave += new System.EventHandler(this.dtpDenngay_Leave);
			// 
			// lblDenngay
			// 
			this.lblDenngay.BackColor = System.Drawing.SystemColors.Control;
			this.lblDenngay.ForeColor = System.Drawing.Color.DarkBlue;
			this.lblDenngay.Location = new System.Drawing.Point(145, 10);
			this.lblDenngay.Name = "lblDenngay";
			this.lblDenngay.Size = new System.Drawing.Size(51, 23);
			this.lblDenngay.TabIndex = 17;
			this.lblDenngay.Text = "đến ngày";
			this.lblDenngay.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// dtpTungay
			// 
			this.dtpTungay.CustomFormat = "dd/MM/yyyy";
			this.dtpTungay.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.dtpTungay.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
			this.dtpTungay.Location = new System.Drawing.Point(64, 9);
			this.dtpTungay.Name = "dtpTungay";
			this.dtpTungay.Size = new System.Drawing.Size(80, 21);
			this.dtpTungay.TabIndex = 16;
			this.dtpTungay.Enter += new System.EventHandler(this.dtpTungay_Enter);
			this.dtpTungay.KeyDown += new System.Windows.Forms.KeyEventHandler(this.event_KeyDown);
			this.dtpTungay.Leave += new System.EventHandler(this.dtpTungay_Leave);
			// 
			// lblTungay
			// 
			this.lblTungay.BackColor = System.Drawing.SystemColors.Control;
			this.lblTungay.ForeColor = System.Drawing.Color.DarkBlue;
			this.lblTungay.Location = new System.Drawing.Point(10, 10);
			this.lblTungay.Name = "lblTungay";
			this.lblTungay.Size = new System.Drawing.Size(49, 23);
			this.lblTungay.TabIndex = 15;
			this.lblTungay.Text = "Từ ngày";
			this.lblTungay.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// grbCheck
			// 
			this.grbCheck.Controls.AddRange(new System.Windows.Forms.Control[] {
																				   this.rdbTheothang,
																				   this.rdbTheongay});
			this.grbCheck.Location = new System.Drawing.Point(9, 10);
			this.grbCheck.Name = "grbCheck";
			this.grbCheck.Size = new System.Drawing.Size(98, 66);
			this.grbCheck.TabIndex = 1;
			this.grbCheck.TabStop = false;
			// 
			// rdbTheothang
			// 
			this.rdbTheothang.ForeColor = System.Drawing.Color.DarkBlue;
			this.rdbTheothang.Location = new System.Drawing.Point(11, 39);
			this.rdbTheothang.Name = "rdbTheothang";
			this.rdbTheothang.Size = new System.Drawing.Size(79, 24);
			this.rdbTheothang.TabIndex = 11;
			this.rdbTheothang.Text = "Theo tháng";
			this.rdbTheothang.CheckedChanged += new System.EventHandler(this.rdbTheothang_CheckedChanged);
			// 
			// rdbTheongay
			// 
			this.rdbTheongay.Checked = true;
			this.rdbTheongay.ForeColor = System.Drawing.Color.DarkBlue;
			this.rdbTheongay.Location = new System.Drawing.Point(11, 8);
			this.rdbTheongay.Name = "rdbTheongay";
			this.rdbTheongay.Size = new System.Drawing.Size(79, 24);
			this.rdbTheongay.TabIndex = 10;
			this.rdbTheongay.TabStop = true;
			this.rdbTheongay.Text = "Theo ngày";
			this.rdbTheongay.CheckedChanged += new System.EventHandler(this.rdbTheongay_CheckedChanged);
			// 
			// lblLoaibc
			// 
			this.lblLoaibc.BackColor = System.Drawing.SystemColors.Control;
			this.lblLoaibc.ForeColor = System.Drawing.Color.DarkBlue;
			this.lblLoaibc.Location = new System.Drawing.Point(16, 294);
			this.lblLoaibc.Name = "lblLoaibc";
			this.lblLoaibc.Size = new System.Drawing.Size(80, 23);
			this.lblLoaibc.TabIndex = 56;
			this.lblLoaibc.Text = "Báo cáo theo :";
			this.lblLoaibc.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.lblLoaibc.Visible = false;
			// 
			// cboLoaibc
			// 
			this.cboLoaibc.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboLoaibc.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.cboLoaibc.ForeColor = System.Drawing.Color.DarkBlue;
			this.cboLoaibc.ImeMode = System.Windows.Forms.ImeMode.NoControl;
			this.cboLoaibc.Items.AddRange(new object[] {
														   "Tất cả",
														   "Tài khoản nợ",
														   "Tài khoản có"});
			this.cboLoaibc.Location = new System.Drawing.Point(103, 294);
			this.cboLoaibc.Name = "cboLoaibc";
			this.cboLoaibc.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.cboLoaibc.Size = new System.Drawing.Size(362, 21);
			this.cboLoaibc.TabIndex = 57;
			this.cboLoaibc.Visible = false;
			this.cboLoaibc.KeyDown += new System.Windows.Forms.KeyEventHandler(this.event_KeyDown);
			this.cboLoaibc.Leave += new System.EventHandler(this.cboLoaibc_Leave);
			this.cboLoaibc.Enter += new System.EventHandler(this.cboLoaibc_Enter);
			// 
			// txtTenmuc
			// 
			this.txtTenmuc.BackColor = System.Drawing.SystemColors.Window;
			this.txtTenmuc.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtTenmuc.ForeColor = System.Drawing.Color.DarkBlue;
			this.txtTenmuc.Location = new System.Drawing.Point(168, 156);
			this.txtTenmuc.Name = "txtTenmuc";
			this.txtTenmuc.ReadOnly = true;
			this.txtTenmuc.Size = new System.Drawing.Size(296, 21);
			this.txtTenmuc.TabIndex = 41;
			this.txtTenmuc.TabStop = false;
			this.txtTenmuc.Text = "";
			this.txtTenmuc.Visible = false;
			this.txtTenmuc.KeyDown += new System.Windows.Forms.KeyEventHandler(this.event_KeyDown);
			// 
			// txtMuc
			// 
			this.txtMuc.BackColor = System.Drawing.SystemColors.Window;
			this.txtMuc.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtMuc.ForeColor = System.Drawing.Color.DarkBlue;
			this.txtMuc.Location = new System.Drawing.Point(103, 156);
			this.txtMuc.Name = "txtMuc";
			this.txtMuc.Size = new System.Drawing.Size(63, 21);
			this.txtMuc.TabIndex = 40;
			this.txtMuc.Text = "";
			this.txtMuc.Visible = false;
			this.txtMuc.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtMuc_KeyDown);
			this.txtMuc.DoubleClick += new System.EventHandler(this.txtMuc_DoubleClick);
			this.txtMuc.Validated += new System.EventHandler(this.txtMuc_Validated);
			this.txtMuc.TextChanged += new System.EventHandler(this.txtMuc_TextChanged);
			this.txtMuc.Enter += new System.EventHandler(this.txtMuc_Enter);
			// 
			// lblMuc
			// 
			this.lblMuc.BackColor = System.Drawing.SystemColors.Control;
			this.lblMuc.ForeColor = System.Drawing.Color.DarkBlue;
			this.lblMuc.Location = new System.Drawing.Point(16, 156);
			this.lblMuc.Name = "lblMuc";
			this.lblMuc.Size = new System.Drawing.Size(80, 23);
			this.lblMuc.TabIndex = 39;
			this.lblMuc.Text = "Mục :";
			this.lblMuc.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.lblMuc.Visible = false;
			// 
			// listMuc
			// 
			this.listMuc.BackColor = System.Drawing.SystemColors.Info;
			this.listMuc.ColumnCount = 0;
			this.listMuc.Location = new System.Drawing.Point(256, 368);
			this.listMuc.MatchBufferTimeOut = 1000;
			this.listMuc.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
			this.listMuc.Name = "listMuc";
			this.listMuc.Size = new System.Drawing.Size(75, 17);
			this.listMuc.TabIndex = 104;
			this.listMuc.TextIndex = -1;
			this.listMuc.TextMember = null;
			this.listMuc.ValueIndex = -1;
			this.listMuc.Visible = false;
			// 
			// txtTenhoatdong
			// 
			this.txtTenhoatdong.BackColor = System.Drawing.SystemColors.Window;
			this.txtTenhoatdong.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtTenhoatdong.ForeColor = System.Drawing.Color.DarkBlue;
			this.txtTenhoatdong.Location = new System.Drawing.Point(168, 202);
			this.txtTenhoatdong.Name = "txtTenhoatdong";
			this.txtTenhoatdong.ReadOnly = true;
			this.txtTenhoatdong.Size = new System.Drawing.Size(296, 21);
			this.txtTenhoatdong.TabIndex = 47;
			this.txtTenhoatdong.TabStop = false;
			this.txtTenhoatdong.Text = "";
			this.txtTenhoatdong.Visible = false;
			this.txtTenhoatdong.KeyDown += new System.Windows.Forms.KeyEventHandler(this.event_KeyDown);
			// 
			// lblHoatdong
			// 
			this.lblHoatdong.BackColor = System.Drawing.SystemColors.Control;
			this.lblHoatdong.ForeColor = System.Drawing.Color.DarkBlue;
			this.lblHoatdong.Location = new System.Drawing.Point(16, 202);
			this.lblHoatdong.Name = "lblHoatdong";
			this.lblHoatdong.Size = new System.Drawing.Size(80, 23);
			this.lblHoatdong.TabIndex = 45;
			this.lblHoatdong.Text = "Hoạt động :";
			this.lblHoatdong.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.lblHoatdong.Visible = false;
			// 
			// txtHoatdong
			// 
			this.txtHoatdong.BackColor = System.Drawing.SystemColors.Window;
			this.txtHoatdong.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtHoatdong.ForeColor = System.Drawing.Color.DarkBlue;
			this.txtHoatdong.Location = new System.Drawing.Point(103, 202);
			this.txtHoatdong.Name = "txtHoatdong";
			this.txtHoatdong.Size = new System.Drawing.Size(63, 21);
			this.txtHoatdong.TabIndex = 46;
			this.txtHoatdong.Text = "";
			this.txtHoatdong.Visible = false;
			this.txtHoatdong.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtHoatdong_KeyDown);
			this.txtHoatdong.DoubleClick += new System.EventHandler(this.txtHoatdong_DoubleClick);
			this.txtHoatdong.Validated += new System.EventHandler(this.txtHoatdong_Validated);
			this.txtHoatdong.TextChanged += new System.EventHandler(this.txtHoatdong_TextChanged);
			// 
			// listHoatdong
			// 
			this.listHoatdong.BackColor = System.Drawing.SystemColors.Info;
			this.listHoatdong.ColumnCount = 0;
			this.listHoatdong.Location = new System.Drawing.Point(424, 368);
			this.listHoatdong.MatchBufferTimeOut = 1000;
			this.listHoatdong.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
			this.listHoatdong.Name = "listHoatdong";
			this.listHoatdong.Size = new System.Drawing.Size(75, 17);
			this.listHoatdong.TabIndex = 106;
			this.listHoatdong.TextIndex = -1;
			this.listHoatdong.TextMember = null;
			this.listHoatdong.ValueIndex = -1;
			this.listHoatdong.Visible = false;
			// 
			// lblError
			// 
			this.lblError.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.lblError.ForeColor = System.Drawing.Color.Maroon;
			this.lblError.Location = new System.Drawing.Point(9, 10);
			this.lblError.Name = "lblError";
			this.lblError.Size = new System.Drawing.Size(470, 120);
			this.lblError.TabIndex = 124;
			this.lblError.Text = "Báo cáo đang xây dựng !";
			this.lblError.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			this.lblError.Visible = false;
			// 
			// txtChuong
			// 
			this.txtChuong.BackColor = System.Drawing.SystemColors.Window;
			this.txtChuong.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtChuong.ForeColor = System.Drawing.Color.DarkBlue;
			this.txtChuong.Location = new System.Drawing.Point(103, 87);
			this.txtChuong.Name = "txtChuong";
			this.txtChuong.Size = new System.Drawing.Size(63, 21);
			this.txtChuong.TabIndex = 31;
			this.txtChuong.Text = "";
			this.txtChuong.Visible = false;
			this.txtChuong.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtChuong_KeyDown);
			this.txtChuong.DoubleClick += new System.EventHandler(this.txtChuong_DoubleClick);
			this.txtChuong.Validated += new System.EventHandler(this.txtChuong_Validated);
			this.txtChuong.TextChanged += new System.EventHandler(this.txtChuong_TextChanged);
			// 
			// lblChuong
			// 
			this.lblChuong.BackColor = System.Drawing.SystemColors.Control;
			this.lblChuong.ForeColor = System.Drawing.Color.DarkBlue;
			this.lblChuong.Location = new System.Drawing.Point(16, 87);
			this.lblChuong.Name = "lblChuong";
			this.lblChuong.Size = new System.Drawing.Size(80, 23);
			this.lblChuong.TabIndex = 30;
			this.lblChuong.Text = "Chương :";
			this.lblChuong.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.lblChuong.Visible = false;
			// 
			// listChuong
			// 
			this.listChuong.BackColor = System.Drawing.SystemColors.Info;
			this.listChuong.ColumnCount = 0;
			this.listChuong.Location = new System.Drawing.Point(8, 368);
			this.listChuong.MatchBufferTimeOut = 1000;
			this.listChuong.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
			this.listChuong.Name = "listChuong";
			this.listChuong.Size = new System.Drawing.Size(75, 17);
			this.listChuong.TabIndex = 101;
			this.listChuong.TextIndex = -1;
			this.listChuong.TextMember = null;
			this.listChuong.ValueIndex = -1;
			this.listChuong.Visible = false;
			// 
			// txtTenchuong
			// 
			this.txtTenchuong.BackColor = System.Drawing.SystemColors.Window;
			this.txtTenchuong.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtTenchuong.ForeColor = System.Drawing.Color.DarkBlue;
			this.txtTenchuong.Location = new System.Drawing.Point(168, 87);
			this.txtTenchuong.Name = "txtTenchuong";
			this.txtTenchuong.ReadOnly = true;
			this.txtTenchuong.Size = new System.Drawing.Size(296, 21);
			this.txtTenchuong.TabIndex = 32;
			this.txtTenchuong.TabStop = false;
			this.txtTenchuong.Text = "";
			this.txtTenchuong.Visible = false;
			this.txtTenchuong.KeyDown += new System.Windows.Forms.KeyEventHandler(this.event_KeyDown);
			// 
			// listKhoaphong
			// 
			this.listKhoaphong.BackColor = System.Drawing.SystemColors.Info;
			this.listKhoaphong.ColumnCount = 0;
			this.listKhoaphong.Location = new System.Drawing.Point(392, 344);
			this.listKhoaphong.MatchBufferTimeOut = 1000;
			this.listKhoaphong.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
			this.listKhoaphong.Name = "listKhoaphong";
			this.listKhoaphong.Size = new System.Drawing.Size(75, 17);
			this.listKhoaphong.TabIndex = 107;
			this.listKhoaphong.TextIndex = -1;
			this.listKhoaphong.TextMember = null;
			this.listKhoaphong.ValueIndex = -1;
			this.listKhoaphong.Visible = false;
			// 
			// txtTenkhoaphong
			// 
			this.txtTenkhoaphong.BackColor = System.Drawing.SystemColors.Window;
			this.txtTenkhoaphong.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtTenkhoaphong.ForeColor = System.Drawing.Color.DarkBlue;
			this.txtTenkhoaphong.Location = new System.Drawing.Point(168, 225);
			this.txtTenkhoaphong.Name = "txtTenkhoaphong";
			this.txtTenkhoaphong.ReadOnly = true;
			this.txtTenkhoaphong.Size = new System.Drawing.Size(296, 21);
			this.txtTenkhoaphong.TabIndex = 50;
			this.txtTenkhoaphong.TabStop = false;
			this.txtTenkhoaphong.Text = "";
			this.txtTenkhoaphong.Visible = false;
			this.txtTenkhoaphong.KeyDown += new System.Windows.Forms.KeyEventHandler(this.event_KeyDown);
			// 
			// txtKhoaphong
			// 
			this.txtKhoaphong.BackColor = System.Drawing.SystemColors.Window;
			this.txtKhoaphong.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtKhoaphong.ForeColor = System.Drawing.Color.DarkBlue;
			this.txtKhoaphong.Location = new System.Drawing.Point(103, 225);
			this.txtKhoaphong.Name = "txtKhoaphong";
			this.txtKhoaphong.Size = new System.Drawing.Size(63, 21);
			this.txtKhoaphong.TabIndex = 49;
			this.txtKhoaphong.Text = "";
			this.txtKhoaphong.Visible = false;
			this.txtKhoaphong.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtKhoaphong_KeyDown);
			this.txtKhoaphong.DoubleClick += new System.EventHandler(this.txtKhoaphong_DoubleClick);
			this.txtKhoaphong.Validated += new System.EventHandler(this.txtKhoaphong_Validated);
			this.txtKhoaphong.TextChanged += new System.EventHandler(this.txtKhoaphong_TextChanged);
			// 
			// lblKhoaphong
			// 
			this.lblKhoaphong.BackColor = System.Drawing.SystemColors.Control;
			this.lblKhoaphong.ForeColor = System.Drawing.Color.DarkBlue;
			this.lblKhoaphong.Location = new System.Drawing.Point(16, 225);
			this.lblKhoaphong.Name = "lblKhoaphong";
			this.lblKhoaphong.Size = new System.Drawing.Size(82, 23);
			this.lblKhoaphong.TabIndex = 48;
			this.lblKhoaphong.Text = "Khoa /phòng :";
			this.lblKhoaphong.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.lblKhoaphong.Visible = false;
			// 
			// listDoituong
			// 
			this.listDoituong.BackColor = System.Drawing.SystemColors.Info;
			this.listDoituong.ColumnCount = 0;
			this.listDoituong.Location = new System.Drawing.Point(16, 352);
			this.listDoituong.MatchBufferTimeOut = 1000;
			this.listDoituong.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
			this.listDoituong.Name = "listDoituong";
			this.listDoituong.Size = new System.Drawing.Size(75, 17);
			this.listDoituong.TabIndex = 108;
			this.listDoituong.TextIndex = -1;
			this.listDoituong.TextMember = null;
			this.listDoituong.ValueIndex = -1;
			this.listDoituong.Visible = false;
			// 
			// txtTendoituong
			// 
			this.txtTendoituong.BackColor = System.Drawing.SystemColors.Window;
			this.txtTendoituong.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtTendoituong.ForeColor = System.Drawing.Color.DarkBlue;
			this.txtTendoituong.Location = new System.Drawing.Point(168, 248);
			this.txtTendoituong.Name = "txtTendoituong";
			this.txtTendoituong.ReadOnly = true;
			this.txtTendoituong.Size = new System.Drawing.Size(296, 21);
			this.txtTendoituong.TabIndex = 53;
			this.txtTendoituong.TabStop = false;
			this.txtTendoituong.Text = "";
			this.txtTendoituong.Visible = false;
			this.txtTendoituong.KeyDown += new System.Windows.Forms.KeyEventHandler(this.event_KeyDown);
			// 
			// txtDoituong
			// 
			this.txtDoituong.BackColor = System.Drawing.SystemColors.Window;
			this.txtDoituong.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtDoituong.ForeColor = System.Drawing.Color.DarkBlue;
			this.txtDoituong.Location = new System.Drawing.Point(103, 248);
			this.txtDoituong.Name = "txtDoituong";
			this.txtDoituong.Size = new System.Drawing.Size(63, 21);
			this.txtDoituong.TabIndex = 52;
			this.txtDoituong.Text = "";
			this.txtDoituong.Visible = false;
			this.txtDoituong.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtDoituong_KeyDown);
			this.txtDoituong.DoubleClick += new System.EventHandler(this.txtDoituong_DoubleClick);
			this.txtDoituong.Validated += new System.EventHandler(this.txtDoituong_Validated);
			this.txtDoituong.TextChanged += new System.EventHandler(this.txtDoituong_TextChanged);
			// 
			// lblDoituong
			// 
			this.lblDoituong.BackColor = System.Drawing.SystemColors.Control;
			this.lblDoituong.ForeColor = System.Drawing.Color.DarkBlue;
			this.lblDoituong.Location = new System.Drawing.Point(16, 248);
			this.lblDoituong.Name = "lblDoituong";
			this.lblDoituong.Size = new System.Drawing.Size(80, 23);
			this.lblDoituong.TabIndex = 51;
			this.lblDoituong.Text = "Đối tượng :";
			this.lblDoituong.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.lblDoituong.Visible = false;
			// 
			// butExcel
			// 
			this.butExcel.BackColor = System.Drawing.SystemColors.Control;
			this.butExcel.ForeColor = System.Drawing.SystemColors.WindowText;
			this.butExcel.Image = ((System.Drawing.Bitmap)(resources.GetObject("butExcel.Image")));
			this.butExcel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butExcel.Location = new System.Drawing.Point(178, 344);
			this.butExcel.Name = "butExcel";
			this.butExcel.Size = new System.Drawing.Size(60, 25);
			this.butExcel.TabIndex = 81;
			this.butExcel.Text = "&Excel";
			this.butExcel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.butExcel.Click += new System.EventHandler(this.butExcel_Click);
			this.butExcel.KeyDown += new System.Windows.Forms.KeyEventHandler(this.event_KeyDown);
			// 
			// lblNhombc
			// 
			this.lblNhombc.BackColor = System.Drawing.SystemColors.Control;
			this.lblNhombc.ForeColor = System.Drawing.Color.DarkBlue;
			this.lblNhombc.Location = new System.Drawing.Point(12, 271);
			this.lblNhombc.Name = "lblNhombc";
			this.lblNhombc.Size = new System.Drawing.Size(86, 23);
			this.lblNhombc.TabIndex = 54;
			this.lblNhombc.Text = "Nhóm báo cáo :";
			this.lblNhombc.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// cboNhombc
			// 
			this.cboNhombc.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.cboNhombc.ForeColor = System.Drawing.Color.DarkBlue;
			this.cboNhombc.ImeMode = System.Windows.Forms.ImeMode.NoControl;
			this.cboNhombc.Items.AddRange(new object[] {
														   "Tất cả",
														   "Tài khoản nợ",
														   "Tài khoản có"});
			this.cboNhombc.Location = new System.Drawing.Point(103, 271);
			this.cboNhombc.Name = "cboNhombc";
			this.cboNhombc.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.cboNhombc.Size = new System.Drawing.Size(362, 21);
			this.cboNhombc.TabIndex = 55;
			this.cboNhombc.KeyDown += new System.Windows.Forms.KeyEventHandler(this.event_KeyDown);
			this.cboNhombc.Leave += new System.EventHandler(this.cboNhombc_Leave);
			this.cboNhombc.Enter += new System.EventHandler(this.cboNhombc_Enter);
			// 
			// txtNhombc
			// 
			this.txtNhombc.BackColor = System.Drawing.SystemColors.Window;
			this.txtNhombc.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtNhombc.ForeColor = System.Drawing.Color.DarkBlue;
			this.txtNhombc.Location = new System.Drawing.Point(103, 271);
			this.txtNhombc.Name = "txtNhombc";
			this.txtNhombc.Size = new System.Drawing.Size(63, 21);
			this.txtNhombc.TabIndex = 52;
			this.txtNhombc.Text = "";
			this.txtNhombc.Visible = false;
			this.txtNhombc.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtNhombc_KeyDown);
			this.txtNhombc.DoubleClick += new System.EventHandler(this.txtNhombc_DoubleClick);
			this.txtNhombc.Validated += new System.EventHandler(this.txtNhombc_Validated);
			this.txtNhombc.TextChanged += new System.EventHandler(this.txtNhombc_TextChanged);
			// 
			// listNhombc
			// 
			this.listNhombc.BackColor = System.Drawing.SystemColors.Info;
			this.listNhombc.ColumnCount = 0;
			this.listNhombc.Location = new System.Drawing.Point(176, 272);
			this.listNhombc.MatchBufferTimeOut = 1000;
			this.listNhombc.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
			this.listNhombc.Name = "listNhombc";
			this.listNhombc.Size = new System.Drawing.Size(75, 17);
			this.listNhombc.TabIndex = 108;
			this.listNhombc.TextIndex = -1;
			this.listNhombc.TextMember = null;
			this.listNhombc.ValueIndex = -1;
			this.listNhombc.Visible = false;
			// 
			// txtKhoanmuc
			// 
			this.txtKhoanmuc.BackColor = System.Drawing.SystemColors.Window;
			this.txtKhoanmuc.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtKhoanmuc.ForeColor = System.Drawing.Color.DarkBlue;
			this.txtKhoanmuc.Location = new System.Drawing.Point(103, 179);
			this.txtKhoanmuc.Name = "txtKhoanmuc";
			this.txtKhoanmuc.Size = new System.Drawing.Size(63, 21);
			this.txtKhoanmuc.TabIndex = 43;
			this.txtKhoanmuc.Text = "";
			this.txtKhoanmuc.Visible = false;
			this.txtKhoanmuc.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtKhoanmuc_KeyDown);
			this.txtKhoanmuc.DoubleClick += new System.EventHandler(this.txtKhoanmuc_DoubleClick);
			this.txtKhoanmuc.Validated += new System.EventHandler(this.txtKhoanmuc_Validated);
			this.txtKhoanmuc.TextChanged += new System.EventHandler(this.txtKhoanmuc_TextChanged);
			this.txtKhoanmuc.Enter += new System.EventHandler(this.txtKhoanmuc_Enter);
			// 
			// lblKhoanmuc
			// 
			this.lblKhoanmuc.BackColor = System.Drawing.SystemColors.Control;
			this.lblKhoanmuc.ForeColor = System.Drawing.Color.DarkBlue;
			this.lblKhoanmuc.Location = new System.Drawing.Point(16, 179);
			this.lblKhoanmuc.Name = "lblKhoanmuc";
			this.lblKhoanmuc.Size = new System.Drawing.Size(80, 23);
			this.lblKhoanmuc.TabIndex = 42;
			this.lblKhoanmuc.Text = "Khoản mục :";
			this.lblKhoanmuc.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.lblKhoanmuc.Visible = false;
			// 
			// listKhoanmuc
			// 
			this.listKhoanmuc.BackColor = System.Drawing.SystemColors.Info;
			this.listKhoanmuc.ColumnCount = 0;
			this.listKhoanmuc.Location = new System.Drawing.Point(336, 376);
			this.listKhoanmuc.MatchBufferTimeOut = 1000;
			this.listKhoanmuc.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
			this.listKhoanmuc.Name = "listKhoanmuc";
			this.listKhoanmuc.Size = new System.Drawing.Size(75, 17);
			this.listKhoanmuc.TabIndex = 105;
			this.listKhoanmuc.TextIndex = -1;
			this.listKhoanmuc.TextMember = null;
			this.listKhoanmuc.ValueIndex = -1;
			this.listKhoanmuc.Visible = false;
			// 
			// txtTenkhoanmuc
			// 
			this.txtTenkhoanmuc.BackColor = System.Drawing.SystemColors.Window;
			this.txtTenkhoanmuc.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtTenkhoanmuc.ForeColor = System.Drawing.Color.DarkBlue;
			this.txtTenkhoanmuc.Location = new System.Drawing.Point(168, 179);
			this.txtTenkhoanmuc.Name = "txtTenkhoanmuc";
			this.txtTenkhoanmuc.ReadOnly = true;
			this.txtTenkhoanmuc.Size = new System.Drawing.Size(296, 21);
			this.txtTenkhoanmuc.TabIndex = 44;
			this.txtTenkhoanmuc.TabStop = false;
			this.txtTenkhoanmuc.Text = "";
			this.txtTenkhoanmuc.Visible = false;
			this.txtTenkhoanmuc.KeyDown += new System.Windows.Forms.KeyEventHandler(this.event_KeyDown);
			// 
			// grpNen
			// 
			this.grpNen.BackColor = System.Drawing.SystemColors.Control;
			this.grpNen.Location = new System.Drawing.Point(9, 70);
			this.grpNen.Name = "grpNen";
			this.grpNen.Size = new System.Drawing.Size(470, 264);
			this.grpNen.TabIndex = 4;
			this.grpNen.TabStop = false;
			// 
			// frmReportCTGS
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(486, 387);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.cboNhombc,
																		  this.txtKhoanmuc,
																		  this.lblKhoanmuc,
																		  this.listKhoanmuc,
																		  this.txtTenkhoanmuc,
																		  this.listNhombc,
																		  this.txtNhombc,
																		  this.lblNhombc,
																		  this.butExcel,
																		  this.lblKhoaphong,
																		  this.listDoituong,
																		  this.txtTendoituong,
																		  this.txtDoituong,
																		  this.lblDoituong,
																		  this.listKhoaphong,
																		  this.txtTenkhoaphong,
																		  this.txtKhoaphong,
																		  this.listChuong,
																		  this.txtTenchuong,
																		  this.txtChuong,
																		  this.lblChuong,
																		  this.txtHoatdong,
																		  this.txtMuc,
																		  this.txtLoaikhoan,
																		  this.txtSotaikhoan,
																		  this.lblHoatdong,
																		  this.lblMuc,
																		  this.lblLoaibc,
																		  this.lblLoaikhoan,
																		  this.lblChucnang,
																		  this.listLoaikhoan,
																		  this.listTaikhoan,
																		  this.listHoatdong,
																		  this.listMuc,
																		  this.txtTenhoatdong,
																		  this.txtTenmuc,
																		  this.cboLoaibc,
																		  this.txtTenloaikhoan,
																		  this.txtTentaikhoan,
																		  this.grbNgay,
																		  this.grbThang,
																		  this.grbCheck,
																		  this.butXem,
																		  this.butKetthuc,
																		  this.butIn,
																		  this.grpNen,
																		  this.lblError});
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.Name = "frmReportCTGS";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.TopMost = true;
			this.Closing += new System.ComponentModel.CancelEventHandler(this.frmReportPublic_Closing);
			this.Load += new System.EventHandler(this.frmReportPublic_Load);
			this.grbThang.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.numDenthang)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.numTuthang)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.numNam)).EndInit();
			this.grbNgay.ResumeLayout(false);
			this.grbCheck.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion
		
		private void frmReportPublic_Load(object sender, System.EventArgs e)
		{
			//Tuy chon form Load
			f_Visible_Control();
			f_Loadform();
			//End tuy chon.

			//Gan gia tri khoi tao cho cac o thang nam
			numTuthang.Value=DateTime.Now.Month;
			numDenthang.Value=DateTime.Now.Month;
			numNam.Value=DateTime.Now.Year;
			numNam.Value=DateTime.Now.Year;
			//
			f_Loaddm();
			dtpTungay.Focus();
		}


		private void f_Visible_Control()
		{
			//Gan label default:
			lblChucnang.Text="Tài khoản :";
			lblMuc.Text="Mục :";
			//
			lblError.Visible=false;
			lblMuc.Visible=false; txtMuc.Visible=false; txtTenmuc.Visible=false; listMuc.Visible=false;
			lblKhoaphong.Visible=false; txtKhoaphong.Visible=false; txtTenkhoaphong.Visible=false; listKhoaphong.Visible=false;
			lblDoituong.Visible=false; txtDoituong.Visible=false; txtTendoituong.Visible=false; listDoituong.Visible=false;
			lblKhoanmuc.Visible=false; txtKhoanmuc.Visible=false; txtTenkhoanmuc.Visible=false; listKhoanmuc.Visible=false;
			lblNhombc.Visible=false; txtNhombc.Visible=false; listNhombc.Visible=false; cboNhombc.Visible=false;
			lblLoaibc.Visible=false; cboLoaibc.Visible=false; 
		}

		private void f_Dispose_Control(bool b_All)
		{
			try
			{
				if (b_All)			
				{ 
					grbCheck.Dispose(); grbNgay.Dispose(); grbThang.Dispose(); grpNen.Dispose(); 
					lblTungay.Dispose(); dtpTungay.Dispose(); lblDenngay.Dispose(); dtpDenngay.Dispose();
					lblTuthang.Dispose(); numTuthang.Dispose(); lblDenthang.Dispose(); numDenthang.Dispose(); lblNam.Dispose(); numNam.Dispose();
					butXem.Dispose(); butExcel.Dispose(); butIn.Dispose(); 
				}
				else lblError.Dispose(); 

				if (!lblChuong.Visible || b_All)			
					{ lblChuong.Dispose(); txtChuong.Dispose(); txtTenchuong.Dispose(); listChuong.Dispose();}

				if (!lblChucnang.Visible || b_All)		
					{ lblChucnang.Dispose(); txtSotaikhoan.Dispose(); txtTentaikhoan.Dispose(); listTaikhoan.Dispose();}

				if (!lblLoaikhoan.Visible || b_All)		
					{ lblLoaikhoan.Dispose(); txtLoaikhoan.Dispose(); txtTenloaikhoan.Dispose(); listLoaikhoan.Dispose();}

				if (!lblMuc.Visible || b_All)			
					{ lblMuc.Dispose(); txtMuc.Dispose(); txtTenmuc.Dispose(); listMuc.Dispose();}
				
				if (!lblKhoanmuc.Visible || b_All)			
				{ lblKhoanmuc.Dispose(); txtKhoanmuc.Dispose(); txtTenkhoanmuc.Dispose(); listKhoanmuc.Dispose();}

				if (!lblHoatdong.Visible || b_All)		
					{ lblHoatdong.Dispose(); txtHoatdong.Dispose(); txtTenhoatdong.Dispose(); listHoatdong.Dispose();}
				
				if (!lblKhoaphong.Visible || b_All)		
					{ lblKhoaphong.Dispose(); txtKhoaphong.Dispose(); txtTenkhoaphong.Dispose(); listKhoaphong.Dispose();}
				
				if (!lblDoituong.Visible || b_All)		
					{ lblDoituong.Dispose(); txtDoituong.Dispose(); txtTendoituong.Dispose(); listDoituong.Dispose();}
				
				if (!lblNhombc.Visible || b_All)			
				{ lblNhombc.Dispose(); txtNhombc.Dispose(); listNhombc.Dispose() ; cboNhombc.Dispose();}

				if (!lblLoaibc.Visible || b_All)			
					{ lblLoaibc.Dispose(); cboLoaibc.Dispose();}
			}
			catch{}	;

		}

		private void f_Loadform()
		{	//i_Kieuin=1 : In theo giay doc; i_Kieuin=2 : In theo giay ngang.
			switch (s_Tenform)
			{			
				case "SDKCTGS":
					f_Loadform_SODKCHUNGTU("SỔ ĐĂNG KÝ CHỨNG TỪ GHI SỔ (MẪU S02b-H)","KT_Sodangkychungtu.rpt","SỔ ĐĂNG KÝ CHỨNG TỪ GHI SỔ","A4",1,1);					
					break;
				case "SCTGS":
					f_Loadform_SOCHUNGTU("CHỨNG TỪ GHI SỔ (MẪU S02a-H)","KT_Chungtughiso.rpt","CHỨNG TỪ GHI SỔ","A4",1,1);					
					break;				
				default:
					f_Loadform_Null();
					break;
			}
		}

		private void f_Loaddm()
		{
			string s_Danhmuc=s_Tenform;			 
			//Load danh muc co cau truc giong form So chung tu ghi so.
			if (s_Tenform=="SDKCTGS" ||s_Tenform=="SCTGS") s_Danhmuc="SOCTGS";

			f_LoadChuong();
			f_LoadLoaikhoan();
			f_LoadHoatdong2();
			f_LoadNhombc();
			switch (s_Danhmuc)
			{				
				case "SOCTGS":
					f_LoadChucnang(ref listTaikhoan,ref dt_Dmtk);
					if (txtSotaikhoan.Text!="") f_LoadLoaictu(ref listMuc,ref dt_Dmmuc,txtSotaikhoan.Text.Trim());
					break;
				default:
					dt_Dmtk=a.get_DMTaikhoan("").Tables[0];
					f_LoadTaikhoan(dt_Dmtk);
					break;
			}
		}


		#region Load danh muc vao cac list.
		private void f_LoadChuong()
		{
			listChuong.DisplayMember="TEN";
			listChuong.TextMember="MA";
			listChuong.ValueMember="TEN";

			dt_Dmchuong=a.get_DMChuong().Tables[0];
			listChuong.DataSource=dt_Dmchuong;
		}

		private void f_LoadTaikhoan(System.Data.DataTable dt_Taikhoan)
		{
			listTaikhoan.DisplayMember="TTK";
			listTaikhoan.TextMember="STK";
			listTaikhoan.ValueMember="TTK";
			listTaikhoan.DataSource=dt_Taikhoan;
		}

		private void f_LoadLoaikhoan()
		{
			listLoaikhoan.DisplayMember="TLK";
			listLoaikhoan.TextMember="LK";
			listLoaikhoan.ValueMember="TLK";

			dt_Dmlk=a.get_DMLoaikhoan().Tables[0];
			listLoaikhoan.DataSource=dt_Dmlk;
		}

		private void f_LoadMuc()
		{
			listMuc.DisplayMember="TTK";
			listMuc.TextMember="MTM";
			listMuc.ValueMember="TTK";

			dt_Dmmuc=a.get_DMMuc().Tables[0];
			listMuc.DataSource=dt_Dmmuc;
		}

		private void f_LoadHoatdong()
		{
			listHoatdong.DisplayMember="TEN";
			listHoatdong.TextMember="MA";
			listHoatdong.ValueMember="TEN";

			dt_Dmhoatdong=a.get_DMHoatdong().Tables[0];
			listHoatdong.DataSource=dt_Dmhoatdong;
		}
		private void f_LoadHoatdong2()
		{
			listHoatdong.DisplayMember="TTK";
			listHoatdong.TextMember="STK";
			listHoatdong.ValueMember="TTK";

			dt_Dmhoatdong=a.get_DMHoatdong().Tables[0];
			listHoatdong.DataSource=dt_Dmhoatdong;
		}

		private void f_LoadChucnang(ref LibList.List listChucnang,ref System.Data.DataTable dt_Dmchucnang)
		{
			listChucnang.DisplayMember="TEN";
			listChucnang.TextMember="MA";
			listChucnang.ValueMember="TEN";

			dt_Dmchucnang=a.get_DMChucnang().Tables[0];
			listChucnang.DataSource=dt_Dmchucnang;
		}

		private void f_LoadLoaictu(ref LibList.List listLoaictu,ref System.Data.DataTable dt_Dmloaictu,string s_IDchucnang)
		{
			listLoaictu.DisplayMember="TEN";
			listLoaictu.TextMember="MASO";
			listLoaictu.ValueMember="TEN";

			dt_Dmloaictu=a.get_DMloaictu(s_IDchucnang).Tables[0];
			listLoaictu.DataSource=dt_Dmloaictu;
		}

		private void f_LoadKhoanmuc(ref LibList.List listKmuc,ref System.Data.DataTable dt_Dmkmuc,string s_IDLoaikhoanmuc)
		{
			listKmuc.DisplayMember="TEN";
			listKmuc.TextMember="MA";
			listKmuc.ValueMember="TEN";

			dt_Dmkmuc=a.get_DMkhoanmuc(s_IDLoaikhoanmuc).Tables[0];
			listKmuc.DataSource=dt_Dmkmuc;
		}

		private void f_LoadNhombc()
		{
//			listNhombc.DisplayMember="TEN";
//			listNhombc.ValueMember="MA";

			dt_Dmnhombc=a.get_DMNhombc().Tables[0];
//			listNhombc.DataSource=dt_Dmnhombc;

			cboNhombc.DisplayMember="TEN";
			cboNhombc.ValueMember="ID";
			cboNhombc.DataSource=dt_Dmnhombc;
			cboNhombc.SelectedIndex=-1;
		}

		private void f_LoadKhoaphong()
		{
			listKhoaphong.DisplayMember="TENKP";
			listKhoaphong.TextMember="MAKP";
			listKhoaphong.ValueMember="TENKP";

			dt_Dmkhoaphong=a.get_DMKhoaphong().Tables[0];
			listKhoaphong.DataSource=dt_Dmkhoaphong;
		}

		private void f_LoadDoituong()
		{
			listDoituong.DisplayMember="TENDT";
			listDoituong.TextMember="MADT";
			listDoituong.ValueMember="TENDT";

			dt_Dmdoituong=a.get_DMDoituong().Tables[0];
			listDoituong.DataSource=dt_Dmdoituong;
		}
		#endregion Load danh muc vao cac list.

		private void f_Hide_List()
		{
			if(!listChuong.Focused) listChuong.Hide();
			if(!listTaikhoan.Focused) listTaikhoan.Hide();
			if(!listLoaikhoan.Focused) listLoaikhoan.Hide();
			if(!listMuc.Focused) listMuc.Hide();
			if(!listKhoanmuc.Focused) listKhoanmuc.Hide();
			if(!listHoatdong.Focused) listHoatdong.Hide();
			if(!listKhoaphong.Focused) listKhoaphong.Hide();
			if(!listDoituong.Focused) listDoituong.Hide();
			if(!listNhombc.Focused) listNhombc.Hide();
		}
		

		private void f_Loadform_BTHCT()
		{
			this.Text="BẢNG TỔNG HỢP CHỨNG TỪ (S01B-H)";
			this.Height=354;
			grpNen.Height=172;
			lblChuong.Visible=true; txtChuong.Visible=true; txtTenchuong.Visible=true;
			lblChuong.Top=87; txtChuong.Top=87; txtTenchuong.Top=87;
			lblChucnang.Visible=true; txtSotaikhoan.Visible=true; txtTentaikhoan.Visible=true;
			lblChucnang.Top=110; txtSotaikhoan.Top=110; txtTentaikhoan.Top=110;
			lblLoaikhoan.Visible=true; txtLoaikhoan.Visible=true; txtTenloaikhoan.Visible=true;
			lblLoaikhoan.Top=133; txtLoaikhoan.Top=133; txtTenloaikhoan.Top=133;
			lblHoatdong.Visible=true; txtHoatdong.Visible=true; txtTenhoatdong.Visible=true;
			lblHoatdong.Top=156; txtHoatdong.Top=156; txtTenhoatdong.Top=156;
			lblNhombc.Visible=true; txtNhombc.Dispose();listNhombc.Dispose(); cboNhombc.Visible=true;
			lblNhombc.Top=179; cboNhombc.Top=179;
			lblLoaibc.Visible=true; cboLoaibc.Visible=true; cboLoaibc.SelectedIndex=0;
			lblLoaibc.Top=202; cboLoaibc.Top=202;

			butXem.Visible=true; butExcel.Visible=true; butIn.Visible=true; butKetthuc.Visible=true;
			butXem.Top=270; butExcel.Top=270; butIn.Top=270; butKetthuc.Top=270;
			i_HChuong=14; i_HTaikhoan=10; i_HLoaikhoan=6; i_HHoatdong=2; i_HNhombc=-3;
			s_Report="KT_Bangtonghopchungtu.rpt";
			i_Kieuin=1; i_Banin=1; //i_Kieuin=1 : In theo giay doc; i_Kieuin=2 : In theo giay ngang.
			s_Pagesize="A4";
			s_fTieude_chinh="BẢNG TỔNG HỢP CHỨNG TỪ";
			f_Dispose_Control(false);

		}

		private void f_Loadform_Null()
		{
			this.Text="BÁO CÁO ĐANG XÂY DỰNG!";
			this.Height=248;
			lblError.Visible=true; lblError.BringToFront();
			butKetthuc.Left=206; butKetthuc.Top=160;
			f_Dispose_Control(true);
		}

		private void f_Loadform_FORMCHUNG(string s_Tieudeform,string s_Filereport,string s_Tieudereport,string s_Giay,int i_In,int i_Soto)
		{
			this.Text=s_Tieudeform;
			this.Height=354;
			grpNen.Height=152;
			lblChuong.Visible=true; txtChuong.Visible=true; txtTenchuong.Visible=true;
			lblChuong.Top=87; txtChuong.Top=87; txtTenchuong.Top=87;
			lblChucnang.Visible=true; txtSotaikhoan.Visible=true; txtTentaikhoan.Visible=true;
			lblChucnang.Top=110; txtSotaikhoan.Top=110; txtTentaikhoan.Top=110;
			lblLoaikhoan.Visible=true; txtLoaikhoan.Visible=true; txtTenloaikhoan.Visible=true;
			lblLoaikhoan.Top=133; txtLoaikhoan.Top=133; txtTenloaikhoan.Top=133;
			lblKhoanmuc.Visible=true; txtKhoanmuc.Visible=true; txtTenkhoanmuc.Visible=true;
			lblKhoanmuc.Top=156; txtKhoanmuc.Top=156; txtTenkhoanmuc.Top=156;
			lblHoatdong.Visible=true; txtHoatdong.Visible=true; txtTenhoatdong.Visible=true;
			lblHoatdong.Top=179; txtHoatdong.Top=179; txtTenhoatdong.Top=179;
			lblNhombc.Visible=true; txtNhombc.Dispose();listNhombc.Dispose(); cboNhombc.Visible=true;
			lblNhombc.Top=202; cboNhombc.Top=202;
			butXem.Visible=true; butExcel.Visible=true; butIn.Visible=true; butKetthuc.Visible=true;
			butXem.Top=270; butExcel.Top=270; butIn.Top=270; butKetthuc.Top=270;
			i_HChuong=14; i_HTaikhoan=10; i_HLoaikhoan=6; i_HKhoanmuc=4 ; i_HHoatdong=2; i_HNhombc=-3;
			s_Report=s_Filereport;
			i_Kieuin=i_In; i_Banin=i_Soto; //i_Kieuin=1 : In theo giay doc; i_Kieuin=2 : In theo giay ngang.
			s_Pagesize=s_Giay;
			s_fTieude_chinh=s_Tieudereport;
			f_Dispose_Control(false);
		}

		//So theo doi tam ung.
		private void f_Loadform_STDTU()
		{
			this.Text="SỔ THEO DÕI TẠM ỨNG";
			this.Height=377;
			grpNen.Height=195;
			lblChuong.Visible=true; txtChuong.Visible=true; txtTenchuong.Visible=true;
			lblChuong.Top=87; txtChuong.Top=87; txtTenchuong.Top=87;
			lblChucnang.Visible=true; txtSotaikhoan.Visible=true; txtTentaikhoan.Visible=true;
			lblChucnang.Top=110; txtSotaikhoan.Top=110; txtTentaikhoan.Top=110;
			lblLoaikhoan.Visible=true; txtLoaikhoan.Visible=true; txtTenloaikhoan.Visible=true;
			lblLoaikhoan.Top=133; txtLoaikhoan.Top=133; txtTenloaikhoan.Top=133;
			lblHoatdong.Visible=true; txtHoatdong.Visible=true; txtTenhoatdong.Visible=true;
			lblHoatdong.Top=156; txtHoatdong.Top=156; txtTenhoatdong.Top=156;
			lblKhoaphong.Visible=true; txtKhoaphong.Visible=true; txtTenkhoaphong.Visible=true;
			lblKhoaphong.Top=179; txtKhoaphong.Top=179; txtTenkhoaphong.Top=179;
			lblDoituong.Visible=true; txtDoituong.Visible=true; txtTendoituong.Visible=true;
			lblDoituong.Top=202; txtDoituong.Top=202; txtTendoituong.Top=202;
			lblNhombc.Visible=true; txtNhombc.Dispose();listNhombc.Dispose(); cboNhombc.Visible=true;
			lblNhombc.Top=225; cboNhombc.Top=225;
			butXem.Visible=true; butExcel.Visible=true; butIn.Visible=true; butKetthuc.Visible=true;
			butXem.Top=293; butExcel.Top=293; butIn.Top=293; butKetthuc.Top=293;
			i_HChuong=6; i_HTaikhoan=6; i_HLoaikhoan=6; i_HHoatdong=6; i_HKhoaphong=2; i_HDoituong=0; i_HNhombc=-3;
			s_Report="KT_Sotheodoitamung.rpt";
			i_Kieuin=2; i_Banin=1; //i_Kieuin=1 : In theo giay doc; i_Kieuin=2 : In theo giay ngang.
			s_Pagesize="A4";
			s_fTieude_chinh="SỔ THEO DÕI TẠM ỨNG";
			f_Dispose_Control(false);
		}

		//So chi tiet cac tai khoan.
		private void f_Loadform_SCTTK()
		{
			this.Text="SỔ CHI TIẾT CÁC TÀI KHOẢN (MẪU SỐ S33-H)";
			this.Height=354;
			grpNen.Height=172;
			lblChuong.Visible=true; txtChuong.Visible=true; txtTenchuong.Visible=true;
			lblChuong.Top=87; txtChuong.Top=87; txtTenchuong.Top=87;
			lblChucnang.Visible=true; txtSotaikhoan.Visible=true; txtTentaikhoan.Visible=true;
			lblChucnang.Top=110; txtSotaikhoan.Top=110; txtTentaikhoan.Top=110;
			lblLoaikhoan.Visible=true; txtLoaikhoan.Visible=true; txtTenloaikhoan.Visible=true;
			lblLoaikhoan.Top=133; txtLoaikhoan.Top=133; txtTenloaikhoan.Top=133;
			lblHoatdong.Visible=true; txtHoatdong.Visible=true; txtTenhoatdong.Visible=true;
			lblHoatdong.Top=156; txtHoatdong.Top=156; txtTenhoatdong.Top=156;
			lblDoituong.Visible=true; txtDoituong.Visible=true; txtTendoituong.Visible=true;
			lblDoituong.Top=179; txtDoituong.Top=179; txtTendoituong.Top=179;
			lblNhombc.Visible=true; txtNhombc.Dispose();listNhombc.Dispose(); cboNhombc.Visible=true;
			lblNhombc.Top=202; cboNhombc.Top=202;
			butXem.Visible=true; butExcel.Visible=true; butIn.Visible=true; butKetthuc.Visible=true;
			butXem.Top=270; butExcel.Top=270; butIn.Top=270; butKetthuc.Top=270;
			i_HChuong=6; i_HTaikhoan=6; i_HLoaikhoan=6; i_HHoatdong=2; i_HDoituong=0; i_HNhombc=-3;
			s_Report="KT_Soctcactaikhoan.rpt";
			i_Kieuin=2; i_Banin=1; //i_Kieuin=1 : In theo giay doc; i_Kieuin=2 : In theo giay ngang.
			s_Pagesize="A4";
			s_fTieude_chinh="SỔ CHI TIẾT CÁC TÀI KHOẢN (MẪU SỐ S33-H)";
			f_Dispose_Control(false);
		}

		private void f_Loadform_SOCHUNGTU(string s_Tieudeform,string s_Filereport,string s_Tieudereport,string s_Giay,int i_In,int i_Soto)
		{
			this.Text=s_Tieudeform;
			this.Height=331;
			grpNen.Height=149;
			lblChuong.Visible=true; txtChuong.Visible=true; txtTenchuong.Visible=true;
			lblChuong.Top=87; txtChuong.Top=87; txtTenchuong.Top=87;
			//Dung txtTaikhoan de load chuc nang.
			lblChucnang.Visible=true; txtSotaikhoan.Visible=true; txtTentaikhoan.Visible=true;
			lblChucnang.Text="Chức năng :";
			lblChucnang.Top=110; txtSotaikhoan.Top=110; txtTentaikhoan.Top=110;
			//End.
			//Dung txtMuc de load loai chung tu.
			lblMuc.Visible=true; txtMuc.Visible=true; txtTenmuc.Visible=true;
			lblMuc.Text="Loại chứng từ :";
			lblMuc.Top=133; txtMuc.Top=133; txtTenmuc.Top=133;
			lblMuc.TabIndex=36; txtMuc.TabIndex=37; txtTenmuc.TabIndex=38;
			//End.
			lblLoaikhoan.Visible=true; txtLoaikhoan.Visible=true; txtTenloaikhoan.Visible=true;
			lblLoaikhoan.Top=156; txtLoaikhoan.Top=156; txtTenloaikhoan.Top=156;
			lblLoaikhoan.TabIndex=39; txtLoaikhoan.TabIndex=40; txtTenloaikhoan.TabIndex=41;
			
			lblHoatdong.Visible=true; txtHoatdong.Visible=true; txtTenhoatdong.Visible=true;
//			lblHoatdong.Top=156; txtHoatdong.Top=156; txtTenhoatdong.Top=156;
            lblHoatdong.Text = "Tài khoản Có :";
			lblHoatdong.Top=179; txtHoatdong.Top=179; txtTenhoatdong.Top=179;

			lblNhombc.Visible=true; txtNhombc.Dispose();listNhombc.Dispose(); cboNhombc.Visible=true;
//			lblNhombc.Top=179; cboNhombc.Top=179;
			lblNhombc.Top=202; cboNhombc.Top=202;

			butXem.Visible=true; butExcel.Visible=true; butIn.Visible=true; butKetthuc.Visible=true;
			butXem.Top=247; butExcel.Top=247; butIn.Top=247; butKetthuc.Top=247;
			i_HChuong=6; i_HTaikhoan=6; i_HLoaikhoan=2; i_HMuc=6;
			s_Report=s_Filereport;
			i_Kieuin=i_In; i_Banin=i_Soto; //i_Kieuin=1 : In theo giay doc; i_Kieuin=2 : In theo giay ngang.
			s_Pagesize=s_Giay;
			s_fTieude_chinh=s_Tieudereport;
			f_Dispose_Control(false);
		}
        private void f_Loadform_SODKCHUNGTU(string s_Tieudeform, string s_Filereport, string s_Tieudereport, string s_Giay, int i_In, int i_Soto)
        {
            this.Text = s_Tieudeform;
            this.Height = 331;
            grpNen.Height = 149;
            lblChuong.Visible = true; txtChuong.Visible = true; txtTenchuong.Visible = true;
            lblChuong.Top = 87; txtChuong.Top = 87; txtTenchuong.Top = 87;
            //Dung txtTaikhoan de load chuc nang.
            lblChucnang.Visible = true; txtSotaikhoan.Visible = true; txtTentaikhoan.Visible = true;
            lblChucnang.Text = "Chức năng :";
            lblChucnang.Top = 110; txtSotaikhoan.Top = 110; txtTentaikhoan.Top = 110;
            //End.
            //Dung txtMuc de load loai chung tu.
            lblMuc.Visible = true; txtMuc.Visible = true; txtTenmuc.Visible = true;
            lblMuc.Text = "Loại chứng từ :";
            lblMuc.Top = 133; txtMuc.Top = 133; txtTenmuc.Top = 133;
            lblMuc.TabIndex = 36; txtMuc.TabIndex = 37; txtTenmuc.TabIndex = 38;
            //End.
            lblLoaikhoan.Visible = true; txtLoaikhoan.Visible = true; txtTenloaikhoan.Visible = true;
            lblLoaikhoan.Top = 156; txtLoaikhoan.Top = 156; txtTenloaikhoan.Top = 156;
            lblLoaikhoan.TabIndex = 39; txtLoaikhoan.TabIndex = 40; txtTenloaikhoan.TabIndex = 41;


            lblNhombc.Visible = true; txtNhombc.Dispose(); listNhombc.Dispose(); cboNhombc.Visible = true;          
            lblNhombc.Top = 179; cboNhombc.Top = 179;

            butXem.Visible = true; butExcel.Visible = true; butIn.Visible = true; butKetthuc.Visible = true;
            butXem.Top = 247; butExcel.Top = 247; butIn.Top = 247; butKetthuc.Top = 247;
            i_HChuong = 6; i_HTaikhoan = 6; i_HLoaikhoan = 2; i_HMuc = 6;
            s_Report = s_Filereport;
            i_Kieuin = i_In; i_Banin = i_Soto; //i_Kieuin=1 : In theo giay doc; i_Kieuin=2 : In theo giay ngang.
            s_Pagesize = s_Giay;
            s_fTieude_chinh = s_Tieudereport;
            f_Dispose_Control(false);
        }

		private void f_Loadform_SCMUC()
		{
			this.Text="SỔ CÁI(CHI TIẾT THEO MỤC)";
			this.Height=354;
			grpNen.Height=172;
			lblChuong.Visible=true; txtChuong.Visible=true; txtTenchuong.Visible=true;
			lblChuong.Top=87; txtChuong.Top=87; txtTenchuong.Top=87;
			lblChucnang.Visible=true; txtSotaikhoan.Visible=true; txtTentaikhoan.Visible=true;
			lblChucnang.Top=110; txtSotaikhoan.Top=110; txtTentaikhoan.Top=110;
			lblLoaikhoan.Visible=true; txtLoaikhoan.Visible=true; txtTenloaikhoan.Visible=true;
			lblLoaikhoan.Top=133; txtLoaikhoan.Top=133; txtTenloaikhoan.Top=133;
			lblMuc.Visible=true; txtMuc.Visible=true; txtTenmuc.Visible=true;
			lblMuc.Top=156; txtMuc.Top=156; txtTenmuc.Top=156;
			lblHoatdong.Visible=true; txtHoatdong.Visible=true; txtTenhoatdong.Visible=true;
			lblHoatdong.Top=179; txtHoatdong.Top=179; txtTenhoatdong.Top=179;
			lblNhombc.Visible=true; txtNhombc.Dispose();listNhombc.Dispose(); cboNhombc.Visible=true;
			lblNhombc.Top=202; cboNhombc.Top=202;

			butXem.Visible=true; butExcel.Visible=true; butIn.Visible=true; butKetthuc.Visible=true;
			butXem.Top=270; butExcel.Top=270; butIn.Top=270; butKetthuc.Top=270;
			i_HChuong=10; i_HTaikhoan=10; i_HLoaikhoan=10; i_HMuc=6; i_HHoatdong=2; i_HNhombc=-3;
			s_Report="KT_Socai_ct_muc.rpt";
			i_Kieuin=1; i_Banin=1; //i_Kieuin=1 : In theo giay doc; i_Kieuin=2 : In theo giay ngang.
			s_Pagesize="A4";
			s_fTieude_chinh="SỔ CÁI";
			f_Dispose_Control(false);

		}


		#region Cac su kien thay doi mau sac khi focus den control.
		private void event_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab || e.KeyValue==13)
			{
				SendKeys.Send("{Tab}");
			}
		}
		
		private void numTuthang_Enter(object sender, System.EventArgs e)
		{
			this.numTuthang.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void numDenthang_Enter(object sender, System.EventArgs e)
		{
			this.numDenthang.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void cboLoaibc_Enter(object sender, System.EventArgs e)
		{
			this.cboLoaibc.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void cboNhombc_Enter(object sender, System.EventArgs e)
		{
			this.cboNhombc.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void numNam_Enter(object sender, System.EventArgs e)
		{
			this.numNam.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void dtpTungay_Enter(object sender, System.EventArgs e)
		{
			this.dtpTungay.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void dtpDenngay_Enter(object sender, System.EventArgs e)
		{
			this.dtpDenngay.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void numTuthang_Leave(object sender, System.EventArgs e)
		{
			this.numTuthang.BackColor = System.Drawing.SystemColors.Window;
			try {if (lblNhombc.Visible) cboNhombc.SelectedIndex=-1;}
			catch{}
		}

		private void numDenthang_Leave(object sender, System.EventArgs e)
		{
			this.numDenthang.BackColor = System.Drawing.SystemColors.Window;
		}

		private void numNam_Leave(object sender, System.EventArgs e)
		{
			this.numNam.BackColor = System.Drawing.SystemColors.Window;
		}

		private void cboLoaibc_Leave(object sender, System.EventArgs e)
		{
			this.cboLoaibc.BackColor = System.Drawing.SystemColors.Window;
		}

		private void cboNhombc_Leave(object sender, System.EventArgs e)
		{
			this.cboNhombc.BackColor = System.Drawing.SystemColors.Window;
		}

		private void dtpTungay_Leave(object sender, System.EventArgs e)
		{
			this.dtpTungay.BackColor = System.Drawing.SystemColors.Window;
			try {if (lblNhombc.Visible) cboNhombc.SelectedIndex=-1;}
			catch{}
		}

		private void dtpDenngay_Leave(object sender, System.EventArgs e)
		{
			this.dtpDenngay.BackColor = System.Drawing.SystemColors.Window;
		}

		#endregion Thay doi mau khi focus den control.

		private void Filter_List(LibList.List listDulieu,string s_Dkloc,string s_Tenfield_1,string s_Tenfield_2)
		{
			try
			{
				string s_Dieukien=s_Tenfield_1.Trim()+" like '%"+s_Dkloc.Trim()+"%'";
				if (s_Tenfield_2.Trim()!="") s_Dieukien+=" or "+s_Tenfield_2.Trim()+" like '%"+s_Dkloc.Trim()+"%'";
				CurrencyManager cm= (CurrencyManager)BindingContext[listDulieu.DataSource];
				System.Data.DataView dv=(System.Data.DataView)cm.List;
				dv.RowFilter=s_Dieukien;
			}
			catch{}
		}


		#region Cac su kien xu ly list khi focus den control.
		private void butKetthuc_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void txtChuong_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (dt_Dmchuong!=null)
			{
				if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listChuong.Focus();
				else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
				{
					if (listChuong.Visible) 
					{
						listChuong.Focus();
						SendKeys.Send("{Down}");
					}
					else SendKeys.Send("{Tab}");
				}
			}
			else SendKeys.Send("{Tab}");
		}

		private void txtChuong_DoubleClick(object sender, System.EventArgs e)
		{
			if (dt_Dmchuong!=null)
			{
				listChuong.Focus();
				Filter_List(listChuong,txtChuong.Text.Trim(),"ma","ten");
				listChuong.BrowseToDmtk(txtChuong,txtTenchuong,txtSotaikhoan,txtChuong.Location.X,txtChuong.Location.Y + txtChuong.Height-2,txtChuong.Width+0+txtTenchuong.Width,txtChuong.Height+i_HChuong,100);
			}
		}

		private void txtChuong_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txtChuong && dt_Dmchuong!=null)
			{
				Filter_List(listChuong,txtChuong.Text.Trim(),"ma","ten");
				listChuong.BrowseToDmtk(txtChuong,txtTenchuong,txtSotaikhoan,txtChuong.Location.X,txtChuong.Location.Y + txtChuong.Height-2,txtChuong.Width+0+txtTenchuong.Width,txtChuong.Height+i_HChuong,100);
			}	
		}

		private void txtChuong_Validated(object sender, System.EventArgs e)
		{
			txtTenchuong.Text="";
			if (txtChuong.Text!="")
			{
				r=a.getrowbyid(dt_Dmchuong,"ma='"+txtChuong.Text.Trim()+"'");
				if (r!=null) 
				{
					txtTenchuong.Text=r["ten"].ToString();
				}
			}
			f_Hide_List();
		}

		private void txtSotaikhoan_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (dt_Dmtk!=null)
			{
				if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listTaikhoan.Focus();
				else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
				{
					if (listTaikhoan.Visible) 
					{
						listTaikhoan.Focus();
						SendKeys.Send("{Down}");
					}
					else SendKeys.Send("{Tab}");
				}
			}
			else SendKeys.Send("{Tab}");
		}

		private void txtSotaikhoan_DoubleClick(object sender, System.EventArgs e)
		{
			if (lblNhombc.Visible) cboNhombc.SelectedIndex=-1;
			if (dt_Dmtk!=null)
			{
				listTaikhoan.Focus();
				switch (s_Tenform)
				{
					case "SDKCTGS":
						Filter_List(listTaikhoan,txtSotaikhoan.Text.Trim(),"ma","ten");
						listTaikhoan.BrowseToDmtk(txtSotaikhoan,txtTentaikhoan,txtMuc,txtSotaikhoan.Location.X,txtSotaikhoan.Location.Y + txtSotaikhoan.Height-2,txtSotaikhoan.Width+0+txtTentaikhoan.Width,txtSotaikhoan.Height+i_HTaikhoan,100);
						break;
					case "SCTGS":
						Filter_List(listTaikhoan,txtSotaikhoan.Text.Trim(),"ma","ten");
						listTaikhoan.BrowseToDmtk(txtSotaikhoan,txtTentaikhoan,txtMuc,txtSotaikhoan.Location.X,txtSotaikhoan.Location.Y + txtSotaikhoan.Height-2,txtSotaikhoan.Width+0+txtTentaikhoan.Width,txtSotaikhoan.Height+i_HTaikhoan,100);
						break;
					default:
						Filter_List(listTaikhoan,txtSotaikhoan.Text.Trim(),"stk","");
						listTaikhoan.BrowseToDmtk(txtSotaikhoan,txtTentaikhoan,txtLoaikhoan,txtSotaikhoan.Location.X,txtSotaikhoan.Location.Y + txtSotaikhoan.Height-2,txtSotaikhoan.Width+0+txtTentaikhoan.Width,txtSotaikhoan.Height+i_HTaikhoan,100);
						break;
				}
			}
		}

		private void txtSotaikhoan_TextChanged(object sender, System.EventArgs e)
		{
			if (lblNhombc.Visible) cboNhombc.SelectedIndex=-1;
			if (this.ActiveControl==txtSotaikhoan && dt_Dmtk!=null)
			{
				switch (s_Tenform)
				{
					case "SDKCTGS":
						Filter_List(listTaikhoan,txtSotaikhoan.Text.Trim(),"ma","ten");
						listTaikhoan.BrowseToDmtk(txtSotaikhoan,txtTentaikhoan,txtMuc,txtSotaikhoan.Location.X,txtSotaikhoan.Location.Y + txtSotaikhoan.Height-2,txtSotaikhoan.Width+0+txtTentaikhoan.Width,txtSotaikhoan.Height+i_HTaikhoan,100);
						break;
					case "SCTGS":
						Filter_List(listTaikhoan,txtSotaikhoan.Text.Trim(),"ma","ten");
						listTaikhoan.BrowseToDmtk(txtSotaikhoan,txtTentaikhoan,txtMuc,txtSotaikhoan.Location.X,txtSotaikhoan.Location.Y + txtSotaikhoan.Height-2,txtSotaikhoan.Width+0+txtTentaikhoan.Width,txtSotaikhoan.Height+i_HTaikhoan,100);
						break;
					default:
						Filter_List(listTaikhoan,txtSotaikhoan.Text.Trim(),"stk","");
						listTaikhoan.BrowseToDmtk(txtSotaikhoan,txtTentaikhoan,txtLoaikhoan,txtSotaikhoan.Location.X,txtSotaikhoan.Location.Y + txtSotaikhoan.Height-2,txtSotaikhoan.Width+0+txtTentaikhoan.Width,txtSotaikhoan.Height+i_HTaikhoan,100);
						break;
				}
			}	
		}

		private void txtSotaikhoan_Validated(object sender, System.EventArgs e)
		{
			string s_Maubaocao=s_Tenform;
			if (s_Tenform=="SDKCTGS" || s_Tenform=="SCTGS") s_Maubaocao="SCTGS";

			txtTentaikhoan.Text="";
			if (txtSotaikhoan.Text!="")
			{
				switch (s_Maubaocao)
				{
					case "SCTGS":
						r=a.getrowbyid(dt_Dmtk,"ma='"+txtSotaikhoan.Text.Trim()+"'");
						if (r!=null) 
						{
							txtTentaikhoan.Text=r["ten"].ToString();
							txtMuc.Text=""; txtTenmuc.Text="";
							b_Lctu=false;
						}
						break;
					default:
						r=a.getrowbyid(dt_Dmtk,"stk='"+txtSotaikhoan.Text.Trim()+"'");
						if (r!=null) 
						{
							txtTentaikhoan.Text=r["ttk"].ToString();
						}
						break;
				}
			}
			try
			{
				if (lblKhoanmuc.Visible){ txtKhoanmuc.Text=""; txtTenkhoanmuc.Text=""; b_Khoanmuc=false; }
			}
			catch{}
			f_Hide_List();
		}
		private void txtLoaikhoan_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (dt_Dmlk!=null)
			{
				if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listLoaikhoan.Focus();
				else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
				{
					if (listLoaikhoan.Visible) 
					{
						listLoaikhoan.Focus();
						SendKeys.Send("{Down}");
					}
					else SendKeys.Send("{Tab}");
				}
			}
			else SendKeys.Send("{Tab}");

		}

		private void txtLoaikhoan_DoubleClick(object sender, System.EventArgs e)
		{
			string s_Maubaocao=s_Tenform;
			if (s_Tenform=="SDKCTGS" || s_Tenform=="SCTGS") s_Maubaocao="SCTGS";			

			if (dt_Dmlk!=null)
			{
				listLoaikhoan.Focus();
				Filter_List(listLoaikhoan,txtLoaikhoan.Text.Trim(),"lk","");
				switch (s_Maubaocao)
				{
					
					case "SCTGS": 
						listLoaikhoan.BrowseToDmtk(txtLoaikhoan,txtTenloaikhoan,cboNhombc,txtLoaikhoan.Location.X,txtLoaikhoan.Location.Y + txtLoaikhoan.Height-2,txtLoaikhoan.Width+0+txtTenloaikhoan.Width,txtLoaikhoan.Height+i_HLoaikhoan,100);
						break;
					default:
						listLoaikhoan.BrowseToDmtk(txtLoaikhoan,txtTenloaikhoan,txtHoatdong,txtLoaikhoan.Location.X,txtLoaikhoan.Location.Y + txtLoaikhoan.Height-2,txtLoaikhoan.Width+0+txtTenloaikhoan.Width,txtLoaikhoan.Height+i_HLoaikhoan,100);
						break;
				}
			}
		}

		private void txtLoaikhoan_TextChanged(object sender, System.EventArgs e)
		{
			string s_Maubaocao=s_Tenform;
			if (s_Tenform=="SDKCTGS" || s_Tenform=="SCTGS") s_Maubaocao="SCTGS";

			if (this.ActiveControl==txtLoaikhoan && dt_Dmlk!=null)
			{
				Filter_List(listLoaikhoan,txtLoaikhoan.Text.Trim(),"lk","");
				switch (s_Maubaocao)
				{
					case "SCTGS": 
						listLoaikhoan.BrowseToDmtk(txtLoaikhoan,txtTenloaikhoan,cboNhombc,txtLoaikhoan.Location.X,txtLoaikhoan.Location.Y + txtLoaikhoan.Height-2,txtLoaikhoan.Width+0+txtTenloaikhoan.Width,txtLoaikhoan.Height+i_HLoaikhoan,100);
						break;
					default:
						listLoaikhoan.BrowseToDmtk(txtLoaikhoan,txtTenloaikhoan,txtHoatdong,txtLoaikhoan.Location.X,txtLoaikhoan.Location.Y + txtLoaikhoan.Height-2,txtLoaikhoan.Width+0+txtTenloaikhoan.Width,txtLoaikhoan.Height+i_HLoaikhoan,100);
						break;
				}
			}	
		}

		private void txtLoaikhoan_Validated(object sender, System.EventArgs e)
		{
			txtTenloaikhoan.Text="";
			if (txtLoaikhoan.Text!="")
			{
				r=a.getrowbyid(dt_Dmlk,"lk='"+txtLoaikhoan.Text.Trim()+"'");
				if (r!=null) 
				{
					txtTenloaikhoan.Text=r["tlk"].ToString();
				}
			}
			f_Hide_List();
		}

		private void txtMuc_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (dt_Dmmuc!=null && b_Lctu)
			{
				if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listMuc.Focus();
				else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
				{
					if (listMuc.Visible) 
					{
						listMuc.Focus();
						SendKeys.Send("{Down}");
					}
					else SendKeys.Send("{Tab}");
				}
			}
			else SendKeys.Send("{Tab}");
		}

		private void txtMuc_DoubleClick(object sender, System.EventArgs e)
		{
			if (dt_Dmmuc!=null && b_Lctu)
			{
				listMuc.Focus();
				switch (s_Tenform)
				{
					case "SDKCTGS":
						Filter_List(listMuc,txtMuc.Text.Trim(),"maso","ten");
						listMuc.BrowseToDmtk(txtMuc,txtTenmuc,txtLoaikhoan,txtMuc.Location.X,txtMuc.Location.Y + txtMuc.Height-2,txtMuc.Width+0+txtTenmuc.Width,txtMuc.Height+i_HMuc,100);
						break;
					case "SCTGS":
						Filter_List(listMuc,txtMuc.Text.Trim(),"maso","ten");
						listMuc.BrowseToDmtk(txtMuc,txtTenmuc,txtLoaikhoan,txtMuc.Location.X,txtMuc.Location.Y + txtMuc.Height-2,txtMuc.Width+0+txtTenmuc.Width,txtMuc.Height+i_HMuc,100);
						break;
					default:
						Filter_List(listMuc,txtMuc.Text.Trim(),"mtm","");
						listMuc.BrowseToDmtk(txtMuc,txtTenmuc,txtHoatdong,txtMuc.Location.X,txtMuc.Location.Y + txtMuc.Height-2,txtMuc.Width+0+txtTenmuc.Width,txtMuc.Height+i_HMuc,100);
						break;
				}
			}
		}

		private void txtMuc_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txtMuc && dt_Dmmuc!=null && b_Lctu)
			{
				switch (s_Tenform)
				{
					case "SDKCTGS":
						Filter_List(listMuc,txtMuc.Text.Trim(),"maso","ten");
						listMuc.BrowseToDmtk(txtMuc,txtTenmuc,txtLoaikhoan,txtMuc.Location.X,txtMuc.Location.Y + txtMuc.Height-2,txtMuc.Width+0+txtTenmuc.Width,txtMuc.Height+i_HMuc,100);
						break;
					case "SCTGS":
						Filter_List(listMuc,txtMuc.Text.Trim(),"maso","ten");
						listMuc.BrowseToDmtk(txtMuc,txtTenmuc,txtLoaikhoan,txtMuc.Location.X,txtMuc.Location.Y + txtMuc.Height-2,txtMuc.Width+0+txtTenmuc.Width,txtMuc.Height+i_HMuc,100);
						break;
					default:
						Filter_List(listMuc,txtMuc.Text.Trim(),"mtm","");
						listMuc.BrowseToDmtk(txtMuc,txtTenmuc,txtHoatdong,txtMuc.Location.X,txtMuc.Location.Y + txtMuc.Height-2,txtMuc.Width+0+txtTenmuc.Width,txtMuc.Height+i_HMuc,100);
						break;
				}
			}	
		}

		private void txtMuc_Validated(object sender, System.EventArgs e)
		{
			txtTenmuc.Text="";
			if (txtMuc.Text!="" && b_Lctu)
			{
				switch (s_Tenform)
				{
					case "SDKCTGS":
						r=a.getrowbyid(dt_Dmmuc,"maso='"+txtMuc.Text.Trim()+"'");
						if (r!=null) 
						{
							txtTenmuc.Text=r["ten"].ToString();
						}
						break;
					case "SCTGS":
						r=a.getrowbyid(dt_Dmmuc,"maso='"+txtMuc.Text.Trim()+"'");
						if (r!=null) 
						{
							txtTenmuc.Text=r["ten"].ToString();
						}
						break;
					default:
						r=a.getrowbyid(dt_Dmmuc,"mtm='"+txtMuc.Text.Trim()+"'");
						if (r!=null) 
						{
							txtTenmuc.Text=r["ttk"].ToString();
						}
						break;
				}
			}
			f_Hide_List();
		}

		private void txtMuc_Enter(object sender, System.EventArgs e)
		{
			string s_Maubaocao=s_Tenform;
			if (s_Tenform=="SDKCTGS" || s_Tenform=="SCTGS") s_Maubaocao="SCTGS";

			switch (s_Maubaocao)
			{
				case "SCTGS":
					try
					{
						if (txtSotaikhoan.Text!="")
						{
							//txtMuc.Enabled=true; txtTenmuc.Enabled=true;
							//txtMuc.Text=""; txtTenmuc.Text="";
							f_LoadLoaictu(ref listMuc,ref dt_Dmmuc,txtSotaikhoan.Text.Trim());
							b_Lctu=true;
						}
						else
						{
							b_Lctu=false;
							txtMuc.Text=""; txtTenmuc.Text="";
							SendKeys.Send("{Tab}");
							//txtMuc.Enabled=false; txtTenmuc.Enabled=false;
						}
					}
					catch
					{
						b_Lctu=false;
						txtMuc.Text=""; txtTenmuc.Text="";
						SendKeys.Send("{Tab}");
					}
					break;
				default:
					b_Lctu=true;
					break;
			}
		}

		private void txtKhoanmuc_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (dt_Dmkhoanmuc!=null && b_Khoanmuc)
			{
				if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listKhoanmuc.Focus();
				else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
				{
					if (listKhoanmuc.Visible) 
					{
						listKhoanmuc.Focus();
						SendKeys.Send("{Down}");
					}
					else SendKeys.Send("{Tab}");
				}
			}
			else SendKeys.Send("{Tab}");
		}

		private void txtKhoanmuc_DoubleClick(object sender, System.EventArgs e)
		{
			if (dt_Dmkhoanmuc!=null && b_Khoanmuc)
			{
				listKhoanmuc.Focus();				
				Filter_List(listKhoanmuc,txtKhoanmuc.Text.Trim(),"ma","ten");
				listKhoanmuc.BrowseToDmtk(txtKhoanmuc,txtTenkhoanmuc,txtHoatdong,txtKhoanmuc.Location.X,txtKhoanmuc.Location.Y + txtKhoanmuc.Height-2,txtKhoanmuc.Width+0+txtTenkhoanmuc.Width,txtKhoanmuc.Height+i_HKhoanmuc,100);				
			}
		}

		private void txtKhoanmuc_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txtKhoanmuc && dt_Dmkhoanmuc!=null && b_Khoanmuc)
			{
				Filter_List(listKhoanmuc,txtKhoanmuc.Text.Trim(),"ma","ten");
				listKhoanmuc.BrowseToDmtk(txtKhoanmuc,txtTenkhoanmuc,txtHoatdong,txtKhoanmuc.Location.X,txtKhoanmuc.Location.Y + txtKhoanmuc.Height-2,txtKhoanmuc.Width+0+txtTenkhoanmuc.Width,txtKhoanmuc.Height+i_HKhoanmuc,100);
			}	
		}

		private void txtKhoanmuc_Validated(object sender, System.EventArgs e)
		{
			txtTenkhoanmuc.Text="";
			if (txtKhoanmuc.Text!="" && b_Khoanmuc)
			{
				switch (s_Tenform)
				{
					default:
						r=a.getrowbyid(dt_Dmkhoanmuc,"ma='"+txtKhoanmuc.Text.Trim()+"'");
						if (r!=null) 
						{
							txtTenkhoanmuc.Text=r["ten"].ToString();
						}
						break;
				}
			}
			f_Hide_List();
		}

		private void txtKhoanmuc_Enter(object sender, System.EventArgs e)
		{
			string s_Maubaocao=s_Tenform;
			if (s_Tenform=="SQTM1" || s_Tenform=="SCMUC" || s_Tenform=="SCTH1" || s_Tenform=="TGNHCT" || 
				s_Tenform=="TGNHTH" || s_Tenform=="SCTTK" || s_Tenform=="STHCN") s_Maubaocao="SKMUC";
			string s_IDloaikm="";

			switch (s_Maubaocao)
			{
				case "SKMUC":
					try
					{
						if (txtSotaikhoan.Text!="")
						{
							//txtMuc.Enabled=true; txtTenmuc.Enabled=true;
							//txtMuc.Text=""; txtTenmuc.Text="";
							s_IDloaikm=a.getrowbyid(dt_Dmtk,"stk='"+txtSotaikhoan.Text.Trim()+"'")["loaikm"].ToString().Trim();
							f_LoadKhoanmuc(ref listKhoanmuc,ref dt_Dmkhoanmuc,s_IDloaikm);
							b_Khoanmuc=true;
						}
						else
						{
							b_Khoanmuc=false;
							txtKhoanmuc.Text=""; txtTenkhoanmuc.Text="";
							SendKeys.Send("{Tab}");
							//txtMuc.Enabled=false; txtTenmuc.Enabled=false;
						}
					}
					catch{b_Khoanmuc=false;}	;
					break;
				default:
					if (lblKhoanmuc.Visible)
					{
						try
						{
							if (txtSotaikhoan.Text!="")
							{
								//txtMuc.Enabled=true; txtTenmuc.Enabled=true;
								//txtMuc.Text=""; txtTenmuc.Text="";
								s_IDloaikm=a.getrowbyid(dt_Dmtk,"stk='"+txtSotaikhoan.Text.Trim()+"'")["loaikm"].ToString().Trim();
								f_LoadKhoanmuc(ref listKhoanmuc,ref dt_Dmkhoanmuc,s_IDloaikm);
								b_Khoanmuc=true;
							}
							else
							{
								b_Khoanmuc=false;
								txtKhoanmuc.Text=""; txtTenkhoanmuc.Text="";
								SendKeys.Send("{Tab}");
								//txtMuc.Enabled=false; txtTenmuc.Enabled=false;
							}
						}
						catch
						{
							b_Khoanmuc=false;
							txtKhoanmuc.Text=""; txtTenkhoanmuc.Text="";
							SendKeys.Send("{Tab}");
						}
					}
					break;
			}
		}

		private void txtHoatdong_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (dt_Dmhoatdong!=null)
			{
				if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listHoatdong.Focus();
				else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
				{
					if (listHoatdong.Visible) 
					{
						listHoatdong.Focus();
						SendKeys.Send("{Down}");
					}
					else SendKeys.Send("{Tab}");
				}
			}
			else SendKeys.Send("{Tab}");
		}

		private void txtHoatdong_DoubleClick(object sender, System.EventArgs e)
		{
			if (dt_Dmhoatdong!=null)
			{
				listHoatdong.Focus();
				Filter_List(listHoatdong,txtHoatdong.Text.Trim(),"ma","ten");
				switch (s_Tenform)
				{
					case "BTHCT": 
						listHoatdong.BrowseToDmtk(txtHoatdong,txtTenhoatdong,cboLoaibc,txtHoatdong.Location.X,txtHoatdong.Location.Y + txtHoatdong.Height-2,txtHoatdong.Width+0+txtTenhoatdong.Width,txtHoatdong.Height+i_HHoatdong,100);
						break;
					case "STDTU": 
						listHoatdong.BrowseToDmtk(txtHoatdong,txtTenhoatdong,txtKhoaphong,txtHoatdong.Location.X,txtHoatdong.Location.Y + txtHoatdong.Height-2,txtHoatdong.Width+0+txtTenhoatdong.Width,txtHoatdong.Height+i_HHoatdong,100);
						break;
					case "SCTTK": 
						listHoatdong.BrowseToDmtk(txtHoatdong,txtTenhoatdong,txtDoituong,txtHoatdong.Location.X,txtHoatdong.Location.Y + txtHoatdong.Height-2,txtHoatdong.Width+0+txtTenhoatdong.Width,txtHoatdong.Height+i_HHoatdong,100);
						break;
					default:
						listHoatdong.BrowseToDmtk(txtHoatdong,txtTenhoatdong,cboNhombc,txtHoatdong.Location.X,txtHoatdong.Location.Y + txtHoatdong.Height-2,txtHoatdong.Width+0+txtTenhoatdong.Width,txtHoatdong.Height+i_HHoatdong,100);
						break;
				}
			}
		}

		private void txtHoatdong_TextChanged(object sender, System.EventArgs e)
		{
//			if (this.ActiveControl==txtHoatdong && dt_Dmhoatdong!=null)
//			{
//				Filter_List(listHoatdong,txtHoatdong.Text.Trim(),"ma","ten");
//				switch (s_Tenform)
//				{
//					case "BTHCT": 
//						listHoatdong.BrowseToDmtk(txtHoatdong,txtTenhoatdong,cboLoaibc,txtHoatdong.Location.X,txtHoatdong.Location.Y + txtHoatdong.Height-2,txtHoatdong.Width+0+txtTenhoatdong.Width,txtHoatdong.Height+i_HHoatdong,100);
//						break;
//					case "STDTU": 
//						listHoatdong.BrowseToDmtk(txtHoatdong,txtTenhoatdong,txtKhoaphong,txtHoatdong.Location.X,txtHoatdong.Location.Y + txtHoatdong.Height-2,txtHoatdong.Width+0+txtTenhoatdong.Width,txtHoatdong.Height+i_HHoatdong,100);
//						break;
//					case "SCTTK": 
//						listHoatdong.BrowseToDmtk(txtHoatdong,txtTenhoatdong,txtDoituong,txtHoatdong.Location.X,txtHoatdong.Location.Y + txtHoatdong.Height-2,txtHoatdong.Width+0+txtTenhoatdong.Width,txtHoatdong.Height+i_HHoatdong,100);
//						break;
//					default:
//						listHoatdong.BrowseToDmtk(txtHoatdong,txtTenhoatdong,cboNhombc,txtHoatdong.Location.X,txtHoatdong.Location.Y + txtHoatdong.Height-2,txtHoatdong.Width+0+txtTenhoatdong.Width,txtHoatdong.Height+i_HHoatdong,100);
//						break;
//				}
//			}
			if (this.ActiveControl==txtHoatdong && dt_Dmhoatdong!=null)
			{
				Filter_List(listHoatdong,txtHoatdong.Text.Trim(),"stk","ttk");
				listHoatdong.BrowseToDmtk(txtHoatdong,txtTenhoatdong,cboNhombc,txtHoatdong.Location.X,txtHoatdong.Location.Y + txtHoatdong.Height-2,txtHoatdong.Width+0+txtTenhoatdong.Width,txtHoatdong.Height+i_HChuong,100);
			}
		}

		private void txtHoatdong_Validated(object sender, System.EventArgs e)
		{
			txtTenhoatdong.Text="";
			if (txtHoatdong.Text!="")
			{
				r=a.getrowbyid(dt_Dmhoatdong,"ma='"+txtHoatdong.Text.Trim()+"'");
				if (r!=null) 
				{
					txtTenhoatdong.Text=r["ten"].ToString();
				}
			}
			f_Hide_List();
		}

		private void txtNhombc_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (dt_Dmnhombc !=null)
			{
				if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listNhombc.Focus();
				else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
				{
					if (listNhombc.Visible) 
					{
						listNhombc.Focus();
						SendKeys.Send("{Down}");
					}
					else SendKeys.Send("{Tab}");
				}
			}
			else SendKeys.Send("{Tab}");
		}

		private void txtNhombc_DoubleClick(object sender, System.EventArgs e)
		{
			if (dt_Dmnhombc!=null)
			{
				listNhombc.Focus();
				Filter_List(listNhombc,txtNhombc.Text.Trim(),"ma","");
				switch (s_Tenform)
				{
					case "BTHCT": 
						listNhombc.BrowseToDmtk(txtNhombc,txtNhombc,cboLoaibc,txtNhombc.Location.X,txtNhombc.Location.Y + txtNhombc.Height-2,txtNhombc.Width+0+cboNhombc.Width,txtNhombc.Height+i_HNhombc,100);
						break;
					case "XXXX": 
						listNhombc.BrowseToDmtk(txtNhombc,txtNhombc,butXem,txtNhombc.Location.X,txtNhombc.Location.Y + txtNhombc.Height-2,txtNhombc.Width+0+cboNhombc.Width,txtNhombc.Height+i_HNhombc,100);
						break;
					default:
						listNhombc.BrowseToDmtk(txtNhombc,txtNhombc,butXem,txtNhombc.Location.X,txtNhombc.Location.Y + txtNhombc.Height-2,txtNhombc.Width+0+cboNhombc.Width,txtNhombc.Height+i_HNhombc,100);
						break;
				}
			}
		}

		private void txtNhombc_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txtNhombc && dt_Dmnhombc!=null)
			{
				Filter_List(listNhombc,txtNhombc.Text.Trim(),"ma","");
				switch (s_Tenform)
				{
					case "BTHCT": 
						listNhombc.BrowseToDmtk(txtNhombc,txtNhombc,cboLoaibc,txtNhombc.Location.X,txtNhombc.Location.Y + txtNhombc.Height-2,txtNhombc.Width+0+cboNhombc.Width,txtNhombc.Height+i_HNhombc,100);
						break;
					case "XXXX": 
						listNhombc.BrowseToDmtk(txtNhombc,txtNhombc,butXem,txtNhombc.Location.X,txtNhombc.Location.Y + txtNhombc.Height-2,txtNhombc.Width+0+cboNhombc.Width,txtNhombc.Height+i_HNhombc,100);
						break;
					default:
						listNhombc.BrowseToDmtk(txtNhombc,txtNhombc,butXem,txtNhombc.Location.X,txtNhombc.Location.Y + txtNhombc.Height-2,txtNhombc.Width+0+cboNhombc.Width,txtNhombc.Height+i_HNhombc,100);
						break;
				}
			}	
		}

		private void txtNhombc_Validated(object sender, System.EventArgs e)
		{
			if (txtNhombc.Text!="")
			{
				r=a.getrowbyid(dt_Dmnhombc,"ma='"+txtNhombc.Text.Trim()+"'");
				if (r!=null) 
				{
					cboNhombc.SelectedValue=int.Parse(r["id"].ToString());
				}
			}
			else cboNhombc.SelectedIndex=-1;
			f_Hide_List();
		}

		private void cboNhombc_SelectedValueChanged(object sender, System.EventArgs e)
		{
//			txtNhombc2.Text="";
//			r=a.getrowbyid(dt_Dmnhombc,"id='"+cboNhombc.SelectedValue.ToString().Trim()+"'");
//			if (r!=null) 
//			{
//				txtNhombc2.Text=r["ten"].ToString();
//			}
//			f_Hide_List();
			//txtNhombc2.Visible=true; txtNhombc2.BringToFront();
		}

		private void txtKhoaphong_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (dt_Dmkhoaphong!=null)
			{
				 if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listKhoaphong.Focus();
				 else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
				 {
					 if (listKhoaphong.Visible) 
					 {
						 listKhoaphong.Focus();
						 SendKeys.Send("{Down}");
					 }
					 else SendKeys.Send("{Tab}");
				 }
			}
			else SendKeys.Send("{Tab}");
		}

		private void txtKhoaphong_DoubleClick(object sender, System.EventArgs e)
		{
			if (dt_Dmkhoaphong!=null)
			{
				listKhoaphong.Focus();
				Filter_List(listKhoaphong,txtKhoaphong.Text.Trim(),"makp","tenkp");
				switch (s_Tenform)
				{
					case "STDTU": 
						listKhoaphong.BrowseToDmtk(txtKhoaphong,txtTenkhoaphong,txtDoituong,txtKhoaphong.Location.X,txtKhoaphong.Location.Y + txtKhoaphong.Height-2,txtKhoaphong.Width+0+txtTenkhoaphong.Width,txtKhoaphong.Height+i_HKhoaphong,100);
						break;
					default:
						listKhoaphong.BrowseToDmtk(txtKhoaphong,txtTenkhoaphong,butXem,txtKhoaphong.Location.X,txtKhoaphong.Location.Y + txtKhoaphong.Height-2,txtKhoaphong.Width+0+txtTenkhoaphong.Width,txtKhoaphong.Height+i_HKhoaphong,100);
						break;
				}
			}
		}

		private void txtKhoaphong_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txtKhoaphong && dt_Dmkhoaphong!=null)
			{
				Filter_List(listKhoaphong,txtKhoaphong.Text.Trim(),"makp","tenkp");
				switch (s_Tenform)
				{
					case "STDTU": 
						listKhoaphong.BrowseToDmtk(txtKhoaphong,txtTenkhoaphong,txtDoituong,txtKhoaphong.Location.X,txtKhoaphong.Location.Y + txtKhoaphong.Height-2,txtKhoaphong.Width+0+txtTenkhoaphong.Width,txtKhoaphong.Height+i_HKhoaphong,100);
						break;
					default:
						listKhoaphong.BrowseToDmtk(txtKhoaphong,txtTenkhoaphong,butXem,txtKhoaphong.Location.X,txtKhoaphong.Location.Y + txtKhoaphong.Height-2,txtKhoaphong.Width+0+txtTenkhoaphong.Width,txtKhoaphong.Height+i_HKhoaphong,100);
						break;
				}
			}	
		}

		private void txtKhoaphong_Validated(object sender, System.EventArgs e)
		{
			txtTenkhoaphong.Text="";
			if (txtKhoaphong.Text!="")
			{
				r=a.getrowbyid(dt_Dmkhoaphong,"makp='"+txtKhoaphong.Text.Trim()+"'");
				if (r!=null) 
				{
					txtTenkhoaphong.Text=r["tenkp"].ToString();
				}
			}
			f_Hide_List();
		}

		private void txtDoituong_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (dt_Dmdoituong!=null)
			{
				if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listDoituong.Focus();
				else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
				{
					if (listDoituong.Visible) 
					{
						listDoituong.Focus();
						SendKeys.Send("{Down}");
					}
					else SendKeys.Send("{Tab}");
				}
			}
			else SendKeys.Send("{Tab}");
		}

		private void txtDoituong_DoubleClick(object sender, System.EventArgs e)
		{
			if (dt_Dmdoituong!=null)
			{
				listDoituong.Focus();
				Filter_List(listDoituong,txtDoituong.Text.Trim(),"madt","tendt");
				switch (s_Tenform)
				{
					case "STDTU": 
						listDoituong.BrowseToDmtk(txtDoituong,txtTendoituong,cboNhombc,txtDoituong.Location.X,txtDoituong.Location.Y + txtDoituong.Height-2,txtDoituong.Width+0+txtTendoituong.Width,txtDoituong.Height+i_HDoituong,100);
						break;
					case "SCTTK": 
						listDoituong.BrowseToDmtk(txtDoituong,txtTendoituong,cboNhombc,txtDoituong.Location.X,txtDoituong.Location.Y + txtDoituong.Height-2,txtDoituong.Width+0+txtTendoituong.Width,txtDoituong.Height+i_HDoituong,100);
						break;
					default:
						listDoituong.BrowseToDmtk(txtDoituong,txtTendoituong,butXem,txtDoituong.Location.X,txtDoituong.Location.Y + txtDoituong.Height-2,txtDoituong.Width+0+txtTendoituong.Width,txtDoituong.Height+i_HDoituong,100);
						break;
				}
			}
		}

		private void txtDoituong_TextChanged(object sender, System.EventArgs e)
		{
//			if (this.ActiveControl==txtDoituong && dt_Dmdoituong!=null)
//			{
//				Filter_List(listDoituong,txtDoituong.Text.Trim(),"madt","tendt");
//				switch (s_Tenform)
//				{
//					case "STDTU": 
//						listDoituong.BrowseToDmtk(txtDoituong,txtTendoituong,cboNhombc,txtDoituong.Location.X,txtDoituong.Location.Y + txtDoituong.Height-2,txtDoituong.Width+0+txtTendoituong.Width,txtDoituong.Height+i_HDoituong,100);
//						break;
//					case "SCTTK": 
//						listDoituong.BrowseToDmtk(txtDoituong,txtTendoituong,cboNhombc,txtDoituong.Location.X,txtDoituong.Location.Y + txtDoituong.Height-2,txtDoituong.Width+0+txtTendoituong.Width,txtDoituong.Height+i_HDoituong,100);
//						break;
//					default:
//						listDoituong.BrowseToDmtk(txtDoituong,txtTendoituong,butXem,txtDoituong.Location.X,txtDoituong.Location.Y + txtDoituong.Height-2,txtDoituong.Width+0+txtTendoituong.Width,txtDoituong.Height+i_HDoituong,100);
//						break;
//				}
//			}	
				
		}


		


		private void txtDoituong_Validated(object sender, System.EventArgs e)
		{
			txtTendoituong.Text="";
			if (txtDoituong.Text!="")
			{
				r=a.getrowbyid(dt_Dmdoituong,"madt='"+txtDoituong.Text.Trim()+"'");
				if (r!=null) 
				{
					txtTendoituong.Text=r["tendt"].ToString();
				}
			}
			f_Hide_List();
		}

		#endregion Xu ly list.

		private bool Kiemtra()
		{
//			switch (s_Tenform)
//			{
//				case "SDKCTGS":
//					break;
//				case "SCTGS":
//					break;				
//				default:
//					if (txtSotaikhoan.Text=="")
//					{
//						MessageBox.Show("Vui lòng nhập số tài khoản!","Chú ý!");
//						txtSotaikhoan.Focus();
//						return false;
//					}
//					break;
//			}
			
			if ((numDenthang.Value<numTuthang.Value)&&(rdbTheothang.Checked))
			{
				MessageBox.Show("Bạn đã chọn từ tháng lớn hơn đến tháng!","Chú ý!");
				numDenthang.Focus();
				return false;
			}
			if (rdbTheongay.Checked)
			{
				if (dtpTungay.Value.Year!=dtpDenngay.Value.Year)
				{
					MessageBox.Show("Bạn chọn số liệu quá nhiều năm!","Chú ý!");
					dtpDenngay.Focus();
					return false;
				}
				if (dtpTungay.Value>dtpDenngay.Value) 
				{
					MessageBox.Show("Bạn đã chọn từ ngày lớn hơn đến ngày!","Chú ý!");
					dtpDenngay.Focus();
					return false;
				}
			}
			return true;
		}

		private void Display(int i_Loai)
		//Loai display: 1 - xuat ra man hinh; 2 - xuat sang excel ; 3 - xuat ra may in. 
		{
			if (Kiemtra()) //Kiem tra dieu kien nhap vao.
			{
				//Gan dieu kien vao cac bien.
				string s_IDtk="",s_IDlk="",s_IDmuc="",s_Nguonns,s_IDchuong="",s_IDhoatdong="",s_IDnhombc="";
				string s_IDchucnang="", s_IDLoaictu="",s_IDkhoaphong="",s_IDdoituong="",s_IDkhoanmuc="";
			
				frmReportPublic_class accMyform=new frmReportPublic_class();
				ds_Data=new System.Data.DataSet();
				//Gan dieu kien ngay thang cho cac bien.
				int yy=rdbTheongay.Checked?int.Parse(dtpTungay.Value.Year.ToString()):int.Parse(numNam.Value.ToString());
				int mm1=rdbTheongay.Checked?int.Parse(dtpTungay.Value.Month.ToString()):int.Parse(numTuthang.Value.ToString());
				int mm2=rdbTheongay.Checked?int.Parse(dtpDenngay.Value.Month.ToString()):int.Parse(numDenthang.Value.ToString());
				string s_mm=mm1.ToString().PadLeft(2,'0');
				string s_yyyy=yy.ToString().Trim();
				string s_yy=s_yyyy.Substring(2,2);
				string s_Tungay=rdbTheongay.Checked?dtpTungay.Value.ToString("dd/MM/yyyy"):numTuthang.Value.ToString().PadLeft(2,'0');//+"/"+numNam.Value.ToString().PadLeft(4,'0');
				string s_Denngay=rdbTheongay.Checked?dtpDenngay.Value.ToString("dd/MM/yyyy"):numDenthang.Value.ToString().PadLeft(2,'0');//+"/"+numNam.Value.ToString().PadLeft(4,'0');
				
				//Kiem tra va canh bao cac thang chua tinh so du.
				string s_Thangnam=a.kt_Tinhsodu(mm1.ToString(),s_yy);
				if (s_Thangnam!="")
				{
					MessageBox.Show("Các tháng "+s_Thangnam.Substring(0,s_Thangnam.Length-1)+" chưa tính số dư!","Chú ý!");
					return;
				}

				if (txtChuong.Text.Trim()!="") s_IDchuong=a.getrowbyid(dt_Dmchuong,"ma='"+txtChuong.Text.Trim()+"'")["id"].ToString().Trim();
				if (txtLoaikhoan.Text.Trim()!="") s_IDlk=a.getrowbyid(dt_Dmlk,"lk='"+txtLoaikhoan.Text.Trim()+"'")["id"].ToString().Trim();
				if (cboNhombc.SelectedIndex>=0) s_IDnhombc=cboNhombc.SelectedValue.ToString();
				if (lblKhoanmuc.Visible && txtKhoanmuc.Text.Trim()!="") s_IDkhoanmuc=a.getrowbyid(dt_Dmkhoanmuc,"ma='"+txtKhoanmuc.Text.Trim()+"'")["id"].ToString().Trim();
                //if (txtHoatdong.Text.Trim() !="") s_IDtk = a.getrowbyid(dt_Dmhoatdong,"ttk='"+txtHoatdong.Text.Trim()+"'")["id"].ToString().Trim();
				switch (s_Tenform)
				{
					case "SDKCTGS":
						if (txtSotaikhoan.Text.Trim()!="") s_IDchucnang=a.getrowbyid(dt_Dmtk,"ma='"+txtSotaikhoan.Text.Trim()+"'")["id"].ToString().Trim();
						if (txtMuc.Text.Trim()!="") s_IDLoaictu=a.getrowbyid(dt_Dmmuc,"maso='"+txtMuc.Text.Trim()+"'")["id"].ToString().Trim();
						break;
					case "SCTGS":
						if (txtSotaikhoan.Text.Trim()!="") s_IDchucnang=a.getrowbyid(dt_Dmtk,"ma='"+txtSotaikhoan.Text.Trim()+"'")["id"].ToString().Trim();
						if (txtMuc.Text.Trim()!="") s_IDLoaictu=a.getrowbyid(dt_Dmmuc,"maso='"+txtMuc.Text.Trim()+"'")["id"].ToString().Trim();
						if(txtHoatdong.Text.Trim() != "") s_IDtk = a.getrowbyid(dt_Dmhoatdong,"stk='"+txtHoatdong.Text.Trim()+"'")["stk"].ToString().Trim();
						break;					
					default:
						s_IDtk=a.get_ID_Stk(txtSotaikhoan.Text.Trim());
						if (txtHoatdong.Text.Trim()!="") s_IDhoatdong=a.getrowbyid(dt_Dmhoatdong,"ma='"+txtHoatdong.Text.Trim()+"'")["id"].ToString().Trim();
						break;
				}
				
				//Load data cua tung mau bao cao.
				switch (s_Tenform)
				{					
					case "SDKCTGS": //Bao cao So dang ky chung tu ghi so (S02b - H).
						ds_Data=accMyform.f_Sodangkyctughiso(a,s_IDchuong,s_IDchucnang,s_IDLoaictu,s_IDlk,s_IDnhombc,s_Tungay,s_Denngay,s_yy,rdbTheongay.Checked);
						accMyform.Dispose();
						break;
					case "SCTGS": //Bao cao Chung tu ghi so.
						ds_Data=accMyform.f_Sochungtughiso(a,s_IDchuong,s_IDchucnang,s_IDLoaictu,s_IDlk, s_IDtk, s_IDnhombc,s_Tungay,s_Denngay,s_yy,rdbTheongay.Checked);
						accMyform.Dispose();
						break;					
					default:
						ds_Data.Clear();
						ds_Data.Dispose();
						break;
				}
				//Ghi DataSet ra file xml de lay cau truc lam report.
				//ds_Data.WriteXml("..\\..\\xml_data\\KT_Soquytienmat.xml",XmlWriteMode.WriteSchema);

				try
				{
					if (ds_Data==null || ds_Data.Tables[0].Rows.Count==0) MessageBox.Show("Không có số liệu !","Thông báo !");
					else
					{
						string s_fTinhchat_tk="0";
						string s_fNgaythang="",s_fGiatri11="",s_fGiatri12="",s_fGiatri21="",s_fGiatri22="";
						string s_fGiatri31="",s_fGiatri32="",s_fGiatri41="",s_fGiatri42="",s_fGiatri51="",s_fGiatri52="";
						f_Loadformula(s_Tungay,s_Denngay,mm1,mm2,yy,ref s_fTinhchat_tk,ref s_fNgaythang,ref s_fGiatri11,
							ref s_fGiatri12,ref s_fGiatri21,ref s_fGiatri22,ref s_fGiatri31,ref s_fGiatri32,
							ref s_fGiatri41,ref s_fGiatri42,ref s_fGiatri51,ref s_fGiatri52);
						
						switch (i_Loai) //i_Loai: 1 - xuat ra man hinh; 2 - xuat sang excel ; 3 - xuat ra may in. 
						{
							case 1:
								frmReport_kt f=new frmReport_kt(a,ds_Data,s_fTieude_chinh,s_fNgaythang,s_fTinhchat_tk,s_fGiatri11,s_fGiatri12,s_fGiatri21,s_fGiatri21,s_fGiatri31,s_fGiatri32,s_fGiatri41,s_fGiatri42,s_fGiatri51,s_fGiatri52,s_Report.ToString());
								f.ShowDialog();
								break;
							case 2:
								string s_ExcelError=exportExcel.expExcel(a,ds_Data,s_fTieude_chinh,s_fNgaythang,s_fTinhchat_tk,s_fGiatri11,s_fGiatri12,s_fGiatri21,s_fGiatri21,s_fGiatri31,s_fGiatri32,s_fGiatri41,s_fGiatri42,s_fGiatri51,s_fGiatri52,s_Report.ToString());
								if (s_ExcelError!="")
									MessageBox.Show(s_ExcelError,"Thông báo!");
								break;
							case 3:
								string s_InError=Print.Printer(a,ds_Data,s_fTieude_chinh,s_fNgaythang,s_fTinhchat_tk,s_fGiatri11,s_fGiatri12,s_fGiatri21,s_fGiatri21,s_fGiatri31,s_fGiatri32,s_fGiatri41,s_fGiatri42,s_fGiatri51,s_fGiatri52,s_Report.ToString(),s_Pagesize,i_Kieuin,i_Banin); //Kieu - ngang hoac doc ; Copy - so ban in.
								if (s_InError=="")
									MessageBox.Show("Đã in xong báo cáo","Thông báo!");
								else MessageBox.Show(s_InError,"Lỗi in báo cáo!");
								break;
							default:
								f=new frmReport_kt(a,ds_Data,s_fTieude_chinh,s_fNgaythang,s_fTinhchat_tk,s_fGiatri11,s_fGiatri12,s_fGiatri21,s_fGiatri21,s_fGiatri31,s_fGiatri32,s_fGiatri41,s_fGiatri42,s_fGiatri51,s_fGiatri52,s_Report.ToString());
								f.ShowDialog();
								break;
						}
					}
				}
				catch
				{
					MessageBox.Show("Không có số liệu !","Thông báo !");
				}
			}
		}

		private void f_Loadformula(string s_Tungay,string s_Denngay,int mm1,int mm2,int yy,
			ref string s_fTinhchat_tk,ref string s_fNgaythang,ref string s_fGiatri11,
			ref string s_fGiatri12,ref string s_fGiatri21,ref string s_fGiatri22,ref string s_fGiatri31,
			ref string s_fGiatri32,ref string s_fGiatri41,ref string s_fGiatri42,ref string s_fGiatri51,ref string s_fGiatri52)
		{
			string s_Stknghang="";
			try {s_fTinhchat_tk=a.getrowbyid(dt_Dmtk,"stk='"+txtSotaikhoan.Text.Trim()+"'")["tinhchat"].ToString().Trim();}
			catch{}
						
			if (rdbTheongay.Checked)
			{
				if (s_Tungay==s_Denngay) s_fNgaythang="Ngày "+s_Tungay;
				else s_fNgaythang="Từ ngày "+s_Tungay+" đến ngày "+s_Denngay;
			}
			else
			{
				if (mm1==mm2) s_fNgaythang="Tháng "+mm1+" năm "+yy;
				else s_fNgaythang="Từ tháng "+mm1+" đến tháng "+mm2+" năm "+yy;
			}
			s_fGiatri11=txtSotaikhoan.Text.Trim();
			s_fGiatri12=txtTentaikhoan.Text.Trim();
						
			switch (s_Tenform)
			{
				case "SDKCTGS": 
					if (txtSotaikhoan.Text!="") s_fTieude_chinh="SỔ ĐĂNG KÝ CHỨNG TỪ GHI SỔ "+txtTentaikhoan.Text.Trim().ToUpper();
					else s_fTieude_chinh="SỔ ĐĂNG KÝ CHỨNG TỪ GHI SỔ";
					break;
				case "SCTGS": 
					if (txtSotaikhoan.Text!="") s_fTieude_chinh="CHỨNG TỪ GHI SỔ "+txtTentaikhoan.Text.Trim().ToUpper();
					else s_fTieude_chinh="CHỨNG TỪ GHI SỔ";
					break;				
				default: 
					break;
			}
		}

		private void butXem_Click(object sender, System.EventArgs e)
		{
			Display(1);
		}

		private void butExcel_Click(object sender, System.EventArgs e)
		{
			Display(2);
		}

		private void butIn_Click(object sender, System.EventArgs e)
		{
			Display(3);
		}

		private void rdbTheothang_CheckedChanged(object sender, System.EventArgs e)
		{
			grbThang.Enabled=rdbTheothang.Checked;
			grbNgay.Enabled=!rdbTheothang.Checked;
		}

		private void rdbTheongay_CheckedChanged(object sender, System.EventArgs e)
		{
			grbThang.Enabled=!rdbTheongay.Checked;
			grbNgay.Enabled=rdbTheongay.Checked;
		}

		private void frmReportPublic_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			try
			{
				if (a!=null) a.Dispose();
				ds_Data.Dispose();
			}
			catch{}	;
			this.Dispose();
		}
	}
}
